Search
Search titles only
By:
Search titles only
By:
Log in
Register
Search
Search titles only
By:
Search titles only
By:
Menu
Install the app
Install
Forums
New posts
All threads
Latest threads
New posts
Trending threads
Trending
Search forums
What's new
New posts
New ads
New profile posts
Latest activity
Free Ads
Latest reviews
Search ads
Members
Current visitors
New profile posts
Search profile posts
Contact us
Latest ads
හොඳ, දැන්වීම්-රහිත (ad-free) ආයුර්වේද ඇප් එකක් සොයා ගැනීමට නොහැකි වූ නිසා, මමම එකක් නිර්මාණය කළා
kitchen_discussions
Updated:
Today at 2:34 AM
Ad icon
Iptv
musicking
Updated:
Sunday at 9:52 AM
Ad icon
ZTE MF283U 4G Unlocked Router (Used)
ayanthamaxi
Updated:
Jul 19, 2026
ලංකාවේ හොඳම උපකාරක පන්ති සහ ගුරුවරුන් එකම තැනකින් - TopTuition.lk
dulithapathum
Updated:
Jul 18, 2026
Colombo
RidhMathraa ’26 🎶✨
Tmadhusanka
Updated:
Jul 15, 2026
Electronics
Vehicles
Property
Search
Reply to thread
Forums
General
ElaKiri Help
Java වැඩ්ඩො
Get the App
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Message
<blockquote data-quote="bigtop" data-source="post: 13256018" data-attributes="member: 407369"><p>Three Tier Architecture කියන්නේ GUI Layer එක, Business Layer එක, Database Layer එක තියෙන Model එකකටයි. මේකේ අනිවාර්යයෙන්ම Database එකක් තියෙන්න ඕනේ නැත්නම් ඒක Three Tier Architecture විදියක් නෑ නේ. කොහොම හරි මම Queue එකක් දාලා Data Insert Three Tier Architecture එකක් හැදුවා. එතකොට මේකේ Data Insert වෙන්නෙත් සහා Database එක හැටියට ක්රියාකරන්නෙත් Queue එකයි/ටයි.</p><p>ඉතුරු ටික ඔයා මේ විදියට බලාගෙන කරන්න. මම ඔක්කොම කරලා දුන්නම ඔයාට ඉගෙන ගන්න දෙයක් ඉතුරු වෙන්නෙ නෑ නේ. ඉතින් ඒක නිසා මේ ටික හොදට refer කරන්න. </p><p>මම ලියපු එක එහෙමම Copy Paste කරන්න එපා. ඒක හොදට බලාගන්න ඊට පස්සේ තමන්ට පුලුවන් විදියට මේ Code එක refer කරන ගමන් තනියෙන්ම code එක ලියන්න. ඒ විදියට තමයි ඉගෙන ගන්න පුලුවන්.</p><p>^.^</p><p></p><p></p><p><strong>ashjFrame Class එක</strong></p><p>[code]</p><p></p><p></p><p></p><p>import java.util.*;</p><p>import java.awt.*;</p><p>import javax.swing.*;</p><p></p><p>public class ashjFrame extends JFrame{</p><p></p><p></p><p> public ashjFrame()</p><p> {</p><p> //==================Initialize the attributes of the jFrame==================</p><p> setTitle("Patient Management System");</p><p> setMaximizedBounds(new Rectangle(640,480));</p><p> setBounds(0,0,640,480);</p><p> setResizable(false);</p><p> setDefaultCloseOperation(EXIT_ON_CLOSE);</p><p> JPanel panelWindow = new ashjPanel();</p><p> this.add(panelWindow);</p><p> }</p><p></p><p></p><p> public static void main(String args[])</p><p> {</p><p> ashjFrame frameWindow = new ashjFrame();</p><p> frameWindow.showFrame();</p><p> }</p><p></p><p></p><p> public void showFrame()</p><p> {</p><p> this.setVisible(true);</p><p> }</p><p></p><p>}</p><p>[/code]</p><p></p><p><strong>ashjPanel Class එක </strong></p><p>[code]</p><p></p><p></p><p>import java.util.*;</p><p>import java.awt.*;</p><p>import javax.swing.*;</p><p>import java.awt.event.*;</p><p></p><p>public class ashjPanel extends JPanel implements ActionListener{</p><p></p><p>//=============Initialize Buttons,Labels,Textboxes================</p><p>JButton btnGotoBoard,btnAdmission;</p><p>JLabel lblPatientID,lblPatientName,lblPatientAddress,lblPatientSickness,lblDoctorName,lblSystemName;</p><p>JLabel lblSpace;</p><p>JTextArea txtaPatientAddress;</p><p>JTextField txtfPatientID,txtfPatientName,txtfDoctorName,txtfPatientSickness;</p><p>int patientId;</p><p>String PatientName,PatientSickness,DoctorName,PatientAddress;</p><p></p><p> public ashjPanel() {</p><p></p><p> //==========Initialize the Grid and Panel==============</p><p> GridBagLayout gridArea = new GridBagLayout();</p><p> this.setLayout(gridArea);</p><p></p><p></p><p> //==========Initialize the Components==============</p><p> btnGotoBoard = new JButton("Go To Board");</p><p> btnAdmission = new JButton("Admission");</p><p> lblPatientID = new JLabel("Patient ID");// <--</p><p> lblPatientName = new JLabel("Patient Name");</p><p> lblPatientAddress = new JLabel("Patient Address");</p><p> lblPatientSickness = new JLabel("Patient Sickness");</p><p> lblDoctorName = new JLabel("Doctor Name");</p><p> lblSystemName = new JLabel("Patient Detail Enter Wizard");</p><p> lblSpace = new JLabel(" ");// <--</p><p> txtfPatientID = new JTextField(10);</p><p> txtfPatientName = new JTextField(19);</p><p> txtaPatientAddress = new JTextArea(8,38);</p><p> txtfDoctorName = new JTextField(38);</p><p> txtfPatientSickness = new JTextField(38);</p><p></p><p> //===========Attach ActionsEvents to Components======</p><p> btnGotoBoard.addActionListener(this);</p><p> btnAdmission.addActionListener(this);</p><p></p><p> //==========Add Components onto the Panel==============</p><p> this.add(lblSpace,setGridAttributes(0,0,0,0,GridBagConstraints.WEST));</p><p> this.add(lblPatientID,setGridAttributes(2,2,1,1,GridBagConstraints.EAST));</p><p> this.add(txtfPatientID,setGridAttributes(3,2,1,1,GridBagConstraints.WEST));</p><p> this.add(lblSpace,setGridAttributes(4,2,1,1,GridBagConstraints.WEST));//for the Blank</p><p> this.add(lblPatientName,setGridAttributes(5,2,1,1,GridBagConstraints.EAST));</p><p> this.add(txtfPatientName,setGridAttributes(6,2,1,1,GridBagConstraints.WEST));// <-- END</p><p> this.add(lblPatientAddress,setGridAttributes(2,5,1,1,GridBagConstraints.EAST));</p><p> this.add(txtaPatientAddress,setGridAttributes(3,5,5,3,GridBagConstraints.WEST));// <-- END</p><p> this.add(lblPatientSickness,setGridAttributes(2,10,1,1,GridBagConstraints.EAST));</p><p> this.add(txtfPatientSickness,setGridAttributes(3,10,5,1,GridBagConstraints.WEST));// <-- END</p><p> this.add(lblDoctorName,setGridAttributes(2,13,1,1,GridBagConstraints.EAST));</p><p> this.add(txtfDoctorName,setGridAttributes(3,13,5,1,GridBagConstraints.WEST));// <-- END</p><p> this.add(btnAdmission,setGridAttributes(4,16,2,1,GridBagConstraints.WEST));</p><p> this.add(btnGotoBoard,setGridAttributes(6,16,1,1,GridBagConstraints.WEST));// <-- END</p><p></p><p> }</p><p></p><p> //==========Specify the Attributes of the Gridbagconstraints==============</p><p> private GridBagConstraints setGridAttributes(int edgeGridX,int edgeGridY,int cellGridHorizontal,int cellGridVertical,int anchor)</p><p> {</p><p> GridBagConstraints gridbgArea = new GridBagConstraints();</p><p> gridbgArea.insets = new Insets(1,1,1,1);</p><p> gridbgArea.ipadx = 0;</p><p> gridbgArea.ipady = 0;</p><p> gridbgArea.gridx = edgeGridX;</p><p> gridbgArea.gridy = edgeGridY;</p><p> gridbgArea.gridheight = cellGridVertical;</p><p> gridbgArea.gridwidth = cellGridHorizontal;</p><p> gridbgArea.anchor = anchor;</p><p> return gridbgArea;</p><p> }</p><p></p><p></p><p> //================================Event Handler=============================</p><p> public void actionPerformed(ActionEvent action)</p><p> {</p><p> Object sourceObj = action.getSource();</p><p></p><p> if(sourceObj == btnGotoBoard)</p><p> {</p><p> //Type your Codes Here asscoaited for GotoBoard.</p><p> }</p><p></p><p> else if(sourceObj == btnAdmission)</p><p> {</p><p> if(txtfPatientID.getText().equalsIgnoreCase("") || txtfPatientName.getText().equalsIgnoreCase("")</p><p> || txtfPatientSickness.getText().equalsIgnoreCase("")</p><p> || txtfDoctorName.getText().equalsIgnoreCase("")</p><p> || txtaPatientAddress.getText().equalsIgnoreCase(""))</p><p> {</p><p> JOptionPane.showMessageDialog(null,"Please Fill the Empty Boxes to Proceed.");</p><p> }</p><p> else</p><p> {</p><p> patientId = Integer.parseInt(txtfPatientID.getText());</p><p> PatientName = txtfPatientName.getText();</p><p> PatientSickness = txtfPatientSickness.getText();</p><p> DoctorName = txtfDoctorName.getText();</p><p> PatientAddress = txtaPatientAddress.getText();</p><p></p><p> ashGetSet getsetObj = new ashGetSet();</p><p> getsetObj = new ashBusiness().receiveValues(patientId,PatientName,PatientAddress,PatientSickness,DoctorName);</p><p></p><p> if(getsetObj.getResult() == true)</p><p> {</p><p> JOptionPane.showMessageDialog(null,"Entering Sucessed");</p><p> }else</p><p> {</p><p> JOptionPane.showMessageDialog(null,"Entering Failed");</p><p> }</p><p> }</p><p> }</p><p></p><p> }</p><p></p><p></p><p>}</p><p>[/code]<strong>ashBusiness Class එක</strong></p><p>[code]</p><p> </p><p>import java.util.*;</p><p>import javax.swing.*;</p><p></p><p>public class ashBusiness {</p><p></p><p> //==============Leave the Default Constructor Alone========== ;)</p><p> public ashBusiness() {</p><p> }</p><p></p><p> public ashGetSet receiveValues(int patientID,String patientName,String patientAddress,String patientSickness,String doctorName)</p><p> {</p><p> ashGetSet setGetObj = new ashGetSet();</p><p> ashDatabase dbObj = new ashDatabase();</p><p> setGetObj.setResult(dbObj.insertQueue(patientID,patientName,patientAddress,patientSickness,doctorName));</p><p> return setGetObj;</p><p> }</p><p></p><p>}</p><p> [/code]</p><p><strong>ashGetSet Class එක </strong></p><p>[code]</p><p> </p><p></p><p>public class ashGetSet {</p><p></p><p> //==============Leave the Default Constructor Alone========== ;)</p><p> public ashGetSet(){</p><p> }</p><p></p><p> //=============Variable Declaration=============</p><p> private int patientID;</p><p> private String patientName,patientAddress,patientSickness,doctorName;</p><p> private boolean boolResult;</p><p></p><p></p><p> //=============Set Patient Info=================</p><p> public void setPatientInfo(int patientID,String patientName,String patientAddress,String patientSickness,String doctorName)</p><p> {</p><p> patientID = patientID;</p><p> patientName = patientName;</p><p> patientAddress = patientAddress;</p><p> patientSickness = patientSickness;</p><p> doctorName = doctorName;</p><p> }</p><p></p><p> //===========Get/Set Result=====================</p><p> public void setResult(boolean result)</p><p> {</p><p> boolResult = result;</p><p> }</p><p></p><p> public boolean getResult()</p><p> {</p><p> return boolResult;</p><p> }</p><p></p><p> //=============Get Patient Info=================</p><p> public int getPatientId()</p><p> {</p><p> return patientID;</p><p> }</p><p></p><p> public String getPatientName()</p><p> {</p><p> return patientName;</p><p> }</p><p></p><p> public String getPatientAddress()</p><p> {</p><p> return patientAddress;</p><p> }</p><p></p><p> public String getpatientSickness()</p><p> {</p><p> return patientSickness;</p><p> }</p><p></p><p> public String getdoctorName()</p><p> {</p><p> return doctorName;</p><p> }</p><p>}</p><p> [/code]</p><p><strong>ashDatabase Class එක </strong></p><p>[code]</p><p> </p><p>import java.util.*;</p><p>import java.util.Iterator;</p><p>import java.util.Queue;</p><p>import java.util.LinkedList;</p><p></p><p></p><p></p><p>public class ashDatabase{</p><p></p><p> //==========Queue List for Storing Data============</p><p> Queue<String> patient = new LinkedList<String>();</p><p> Iterator it = patient.iterator();</p><p></p><p> //=================Insert Values and Retrieve the Response Boolean Value==============</p><p> public boolean insertQueue(int patientID,String patientName,String patientAddress,String patientSickness,String doctorName)</p><p> {</p><p> patient.offer(Integer.toString(patientID));</p><p> patient.offer(patientName);</p><p> patient.offer(patientAddress);</p><p> patient.offer(patientSickness);</p><p> patient.offer(doctorName);</p><p></p><p> if(5 == patient.size())</p><p> {</p><p> return true; //Entering Sucessed</p><p> }</p><p> else</p><p> {</p><p> return false; //Entering Failed</p><p> }</p><p></p><p> }</p><p></p><p></p><p>/*</p><p> public string getPatientID()</p><p> {</p><p> string patientId = (String)patient.poll();</p><p> return patientId ;</p><p></p><p> }</p><p></p><p> public string getPatientName()</p><p> {</p><p> string patientName = (String)patient.poll();</p><p> return patientName ;</p><p></p><p></p><p> }</p><p> public string getPatientAddress()</p><p> {</p><p> string patientAddress = (String)patient.poll();</p><p> return patientAddress</p><p></p><p></p><p> }</p><p> public string getPatientSikness()</p><p> {</p><p> string patientSikness = (String)patient.poll();</p><p> return patientSikness;</p><p></p><p></p><p> }</p><p> public string getDoctorName()</p><p> {</p><p> string doctorName = (String)patient.poll();</p><p> return doctorName;</p><p></p><p> }</p><p> */</p><p>}</p><p> [/code]</p></blockquote><p></p>
[QUOTE="bigtop, post: 13256018, member: 407369"] Three Tier Architecture කියන්නේ GUI Layer එක, Business Layer එක, Database Layer එක තියෙන Model එකකටයි. මේකේ අනිවාර්යයෙන්ම Database එකක් තියෙන්න ඕනේ නැත්නම් ඒක Three Tier Architecture විදියක් නෑ නේ. කොහොම හරි මම Queue එකක් දාලා Data Insert Three Tier Architecture එකක් හැදුවා. එතකොට මේකේ Data Insert වෙන්නෙත් සහා Database එක හැටියට ක්රියාකරන්නෙත් Queue එකයි/ටයි. ඉතුරු ටික ඔයා මේ විදියට බලාගෙන කරන්න. මම ඔක්කොම කරලා දුන්නම ඔයාට ඉගෙන ගන්න දෙයක් ඉතුරු වෙන්නෙ නෑ නේ. ඉතින් ඒක නිසා මේ ටික හොදට refer කරන්න. මම ලියපු එක එහෙමම Copy Paste කරන්න එපා. ඒක හොදට බලාගන්න ඊට පස්සේ තමන්ට පුලුවන් විදියට මේ Code එක refer කරන ගමන් තනියෙන්ම code එක ලියන්න. ඒ විදියට තමයි ඉගෙන ගන්න පුලුවන්. ^.^ [B]ashjFrame Class එක[/B] [code] import java.util.*; import java.awt.*; import javax.swing.*; public class ashjFrame extends JFrame{ public ashjFrame() { //==================Initialize the attributes of the jFrame================== setTitle("Patient Management System"); setMaximizedBounds(new Rectangle(640,480)); setBounds(0,0,640,480); setResizable(false); setDefaultCloseOperation(EXIT_ON_CLOSE); JPanel panelWindow = new ashjPanel(); this.add(panelWindow); } public static void main(String args[]) { ashjFrame frameWindow = new ashjFrame(); frameWindow.showFrame(); } public void showFrame() { this.setVisible(true); } } [/code] [B]ashjPanel Class එක [/B] [code] import java.util.*; import java.awt.*; import javax.swing.*; import java.awt.event.*; public class ashjPanel extends JPanel implements ActionListener{ //=============Initialize Buttons,Labels,Textboxes================ JButton btnGotoBoard,btnAdmission; JLabel lblPatientID,lblPatientName,lblPatientAddress,lblPatientSickness,lblDoctorName,lblSystemName; JLabel lblSpace; JTextArea txtaPatientAddress; JTextField txtfPatientID,txtfPatientName,txtfDoctorName,txtfPatientSickness; int patientId; String PatientName,PatientSickness,DoctorName,PatientAddress; public ashjPanel() { //==========Initialize the Grid and Panel============== GridBagLayout gridArea = new GridBagLayout(); this.setLayout(gridArea); //==========Initialize the Components============== btnGotoBoard = new JButton("Go To Board"); btnAdmission = new JButton("Admission"); lblPatientID = new JLabel("Patient ID");// <-- lblPatientName = new JLabel("Patient Name"); lblPatientAddress = new JLabel("Patient Address"); lblPatientSickness = new JLabel("Patient Sickness"); lblDoctorName = new JLabel("Doctor Name"); lblSystemName = new JLabel("Patient Detail Enter Wizard"); lblSpace = new JLabel(" ");// <-- txtfPatientID = new JTextField(10); txtfPatientName = new JTextField(19); txtaPatientAddress = new JTextArea(8,38); txtfDoctorName = new JTextField(38); txtfPatientSickness = new JTextField(38); //===========Attach ActionsEvents to Components====== btnGotoBoard.addActionListener(this); btnAdmission.addActionListener(this); //==========Add Components onto the Panel============== this.add(lblSpace,setGridAttributes(0,0,0,0,GridBagConstraints.WEST)); this.add(lblPatientID,setGridAttributes(2,2,1,1,GridBagConstraints.EAST)); this.add(txtfPatientID,setGridAttributes(3,2,1,1,GridBagConstraints.WEST)); this.add(lblSpace,setGridAttributes(4,2,1,1,GridBagConstraints.WEST));//for the Blank this.add(lblPatientName,setGridAttributes(5,2,1,1,GridBagConstraints.EAST)); this.add(txtfPatientName,setGridAttributes(6,2,1,1,GridBagConstraints.WEST));// <-- END this.add(lblPatientAddress,setGridAttributes(2,5,1,1,GridBagConstraints.EAST)); this.add(txtaPatientAddress,setGridAttributes(3,5,5,3,GridBagConstraints.WEST));// <-- END this.add(lblPatientSickness,setGridAttributes(2,10,1,1,GridBagConstraints.EAST)); this.add(txtfPatientSickness,setGridAttributes(3,10,5,1,GridBagConstraints.WEST));// <-- END this.add(lblDoctorName,setGridAttributes(2,13,1,1,GridBagConstraints.EAST)); this.add(txtfDoctorName,setGridAttributes(3,13,5,1,GridBagConstraints.WEST));// <-- END this.add(btnAdmission,setGridAttributes(4,16,2,1,GridBagConstraints.WEST)); this.add(btnGotoBoard,setGridAttributes(6,16,1,1,GridBagConstraints.WEST));// <-- END } //==========Specify the Attributes of the Gridbagconstraints============== private GridBagConstraints setGridAttributes(int edgeGridX,int edgeGridY,int cellGridHorizontal,int cellGridVertical,int anchor) { GridBagConstraints gridbgArea = new GridBagConstraints(); gridbgArea.insets = new Insets(1,1,1,1); gridbgArea.ipadx = 0; gridbgArea.ipady = 0; gridbgArea.gridx = edgeGridX; gridbgArea.gridy = edgeGridY; gridbgArea.gridheight = cellGridVertical; gridbgArea.gridwidth = cellGridHorizontal; gridbgArea.anchor = anchor; return gridbgArea; } //================================Event Handler============================= public void actionPerformed(ActionEvent action) { Object sourceObj = action.getSource(); if(sourceObj == btnGotoBoard) { //Type your Codes Here asscoaited for GotoBoard. } else if(sourceObj == btnAdmission) { if(txtfPatientID.getText().equalsIgnoreCase("") || txtfPatientName.getText().equalsIgnoreCase("") || txtfPatientSickness.getText().equalsIgnoreCase("") || txtfDoctorName.getText().equalsIgnoreCase("") || txtaPatientAddress.getText().equalsIgnoreCase("")) { JOptionPane.showMessageDialog(null,"Please Fill the Empty Boxes to Proceed."); } else { patientId = Integer.parseInt(txtfPatientID.getText()); PatientName = txtfPatientName.getText(); PatientSickness = txtfPatientSickness.getText(); DoctorName = txtfDoctorName.getText(); PatientAddress = txtaPatientAddress.getText(); ashGetSet getsetObj = new ashGetSet(); getsetObj = new ashBusiness().receiveValues(patientId,PatientName,PatientAddress,PatientSickness,DoctorName); if(getsetObj.getResult() == true) { JOptionPane.showMessageDialog(null,"Entering Sucessed"); }else { JOptionPane.showMessageDialog(null,"Entering Failed"); } } } } } [/code][B]ashBusiness Class එක[/B] [code] import java.util.*; import javax.swing.*; public class ashBusiness { //==============Leave the Default Constructor Alone========== ;) public ashBusiness() { } public ashGetSet receiveValues(int patientID,String patientName,String patientAddress,String patientSickness,String doctorName) { ashGetSet setGetObj = new ashGetSet(); ashDatabase dbObj = new ashDatabase(); setGetObj.setResult(dbObj.insertQueue(patientID,patientName,patientAddress,patientSickness,doctorName)); return setGetObj; } } [/code] [B]ashGetSet Class එක [/B] [code] public class ashGetSet { //==============Leave the Default Constructor Alone========== ;) public ashGetSet(){ } //=============Variable Declaration============= private int patientID; private String patientName,patientAddress,patientSickness,doctorName; private boolean boolResult; //=============Set Patient Info================= public void setPatientInfo(int patientID,String patientName,String patientAddress,String patientSickness,String doctorName) { patientID = patientID; patientName = patientName; patientAddress = patientAddress; patientSickness = patientSickness; doctorName = doctorName; } //===========Get/Set Result===================== public void setResult(boolean result) { boolResult = result; } public boolean getResult() { return boolResult; } //=============Get Patient Info================= public int getPatientId() { return patientID; } public String getPatientName() { return patientName; } public String getPatientAddress() { return patientAddress; } public String getpatientSickness() { return patientSickness; } public String getdoctorName() { return doctorName; } } [/code] [B]ashDatabase Class එක [/B] [code] import java.util.*; import java.util.Iterator; import java.util.Queue; import java.util.LinkedList; public class ashDatabase{ //==========Queue List for Storing Data============ Queue<String> patient = new LinkedList<String>(); Iterator it = patient.iterator(); //=================Insert Values and Retrieve the Response Boolean Value============== public boolean insertQueue(int patientID,String patientName,String patientAddress,String patientSickness,String doctorName) { patient.offer(Integer.toString(patientID)); patient.offer(patientName); patient.offer(patientAddress); patient.offer(patientSickness); patient.offer(doctorName); if(5 == patient.size()) { return true; //Entering Sucessed } else { return false; //Entering Failed } } /* public string getPatientID() { string patientId = (String)patient.poll(); return patientId ; } public string getPatientName() { string patientName = (String)patient.poll(); return patientName ; } public string getPatientAddress() { string patientAddress = (String)patient.poll(); return patientAddress } public string getPatientSikness() { string patientSikness = (String)patient.poll(); return patientSikness; } public string getDoctorName() { string doctorName = (String)patient.poll(); return doctorName; } */ } [/code] [/QUOTE]
Insert quotes…
Verification
Nawa warak dahaya keeyada? (Namaya wadi kireema dahaya)
Post reply
Top
Bottom