Alignment problem


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 5 of 5

Thread: Alignment problem

  1. #1
    Join Date
    Apr 2006
    Posts
    7

    Alignment problem

    I got a problem with one of my interface...

    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??

    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);
    Attached Images Attached Images

  2. #2
    Join Date
    Apr 2006
    Posts
    7
    isn't there anyone who can help???

  3. #3
    Join Date
    Dec 2004
    Location
    San Bernardino County, California
    Posts
    1,468
    Have you attempted to play with the Vgap between the two elements of your GridLayout?

    Can you limit the size of your panMain3 - might what you're seeing is that panel grabbing too much space?

    Have you tried creating a third (empty) panel to add to pan1and3 after you add panMain3?

  4. #4
    Join Date
    Apr 2006
    Posts
    7
    i have managed to solve it already...

    thanks anyways nspils..

  5. #5
    Join Date
    Jan 2006
    Location
    Ireland
    Posts
    62
    Why not post up your solution, it may help other forum users in future who have the same problem.

    Kind regards,
    Noel
    Efficiency is intelligent laziness

Similar Threads

  1. Problem with Search
    By Irina in forum ASP.NET
    Replies: 0
    Last Post: 11-29-2002, 10:47 PM
  2. Replies: 0
    Last Post: 12-13-2001, 12:06 PM
  3. a problem with font and language
    By Roseta in forum VB Classic
    Replies: 0
    Last Post: 11-14-2001, 03:24 AM
  4. Arabic problem view
    By Ayman in forum VB Classic
    Replies: 0
    Last Post: 04-03-2000, 01:08 AM
  5. Problem with CryptoAPI and JCE
    By Jason Bock in forum VB Classic
    Replies: 0
    Last Post: 03-21-2000, 06:48 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center