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");
}
}
}
}
}