Alignment problem
The last line, which is in the panMain2 appears way off than the others.. have tried many time to re-align but to no avail.. THe "follow up" and 2 radio buttons seem all the way at the bottom... How can i bring them to be n correct order??
Can anyone please advise?? :confused:
Attached is the screen shot for ref..
//---------- create Control Panel for button
JPanel panControl = new JPanel();
panControl.setLayout(new FlowLayout());
panControl.setBorder(new CompoundBorder(new EtchedBorder(), new EmptyBorder(10, 10, 10 ,10)));
panControl.add(Box.createRigidArea(new Dimension(50, 1)));
panControl.setBackground(bg1);
// create Control Panel objects
button = new JButton[3];
String lblButton [] = {"Save" , "Clear" ,"Back to Main"};
for (int i=0; i<button.length; i++)
{
button[i] = new JButton(lblButton[i]);
button[i].setFont(f2);
button[i].setForeground(Color.black);
button[i].addActionListener(this);
button[i].setBackground(bg);
}
button[0].setMnemonic('S');
button[1].setMnemonic('C');
button[2].setMnemonic('B');
// place the object into the Control Panel
for (int i = 0; i<button.length; i++)
{
panControl.add(button[i]);
panControl.add(Box.createRigidArea(new Dimension(5, 1)));
}
// ----------- create Main Panel
JPanel panMain = new JPanel();
panMain.setLayout(new GridLayout(0, 2, 0, 5));
// create panMain objects
textField = new JTextField[8];
String lblTextField[] = {"Patient No.", "Register Date", "First name", "Last Name",
"Doctor Name", "Diagnosis", "Perscription", "Follow-Up Appointment"};
JLabel lblIndex[];
lblIndex = new JLabel[8];
for(int i=0; i<lblIndex.length; i++)
{
lblIndex[i] = new JLabel(lblTextField[i]);
lblIndex[i].setForeground(fg);
lblIndex[i].setFont(f2);
}
textField = new JTextField[8];
for(int i=1; i<lblIndex.length; i++)
{
textField[i] = new JTextField();
textField[i].setPreferredSize(new Dimension(250, 25));
textField[i].setFont(new Font("Bookman Old Style", Font.BOLD,14));
}
// create sub panel : panRegNo
JPanel panRegNo = new JPanel();
panRegNo.setLayout(new GridLayout(1, 1, 1, 0));
panRegNo.setBackground(bg);
// place objects into Main Panel
panMain.add(lblIndex[0]);
panMain.add(panRegNo);
panMain.add(lblIndex[1]);
panMain.add(textField[1]);
panMain.add(lblIndex[2]);
panMain.add(textField[2]);
panMain.add(lblIndex[3]);
panMain.add(textField[3]);
panMain.add(lblIndex[4]);
panMain.add(panDoctorName);
panMain.add(lblIndex[5]);
panMain.add(textField[5]);
panMain.add(lblIndex[6]);
panMain.add(textField[6]);
// ----------- create Main3 Panel
JPanel panMain3 = new JPanel();
panMain3.setLayout(new GridLayout(0, 2, 0, 5));
// sub panel Follow Up
JPanel panFollowUp = new JPanel();
FollowUpRadioListener followUpRadioListener;
followUpRadioListener = new FollowUpRadioListener();
String followUp[] = {"Yes", "No"};
grpFollowUp = new ButtonGroup();
panFollowUp.setLayout(new GridLayout(1, 0));
radFollowUp = new JRadioButton[2];
for(int i=0; i<2; i++)
{
radFollowUp[i] = new JRadioButton(followUp[i]);
radFollowUp[i].setFont(f2);
radFollowUp[i].addActionListener(followUpRadioListener);
grpFollowUp.add(radFollowUp[i]);
panFollowUp.add(radFollowUp[i]);
}
// create Main3 Panel objects
textField3 = new JTextField[1];
String lblTextField3[] = {"Follow Up"};
JLabel lblIndex3[];
lblIndex3 = new JLabel[1];
for(int i=0; i<lblIndex3.length; i++)
{
lblIndex3[i] = new JLabel(lblTextField3[i]);
lblIndex3[i].setForeground(fg);
lblIndex3[i].setFont(f2);
}
// place an object into the Main3 Panel
panMain3.add(lblIndex3[0]);
panMain3.add(panFollowUp);
// ------- create Panel to put object of panMain and panMain3
JPanel pan1and3 = new JPanel();
pan1and3.setLayout(new GridLayout(0, 1, 0, 5));
pan1and3.setBorder(new TitledBorder(new EtchedBorder(), "Medical Details"));
pan1and3.add(panMain);
pan1and3.add(panMain3);
// place the Panels on Screen
this.setLayout(new BorderLayout());
this.add(pan1and3, BorderLayout.CENTER);
this.add(panControl, BorderLayout.SOUTH);
frmMain = new JFrame("Add Medical Details");
frmMain.getContentPane().setLayout(new FlowLayout());
frmMain.setLocation(200, 30);
frmMain.setResizable(false);
frmMain.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frmMain.getContentPane().add(this);
frmMain.pack();
frmMain.setVisible(true);

