Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Java JPanel Help

Options
  • 20-02-2006 11:45am
    #1
    Registered Users Posts: 618 ✭✭✭


    Hi all,

    Does anybody know how you can center alignment textboxs, Jbuttons etc within a JPanel in Java.

    The situation is that I have 3 sets of Jbuttons with JTextfields, and I want to have 1 on the lefthand side, 2nd in the middle and the 3rd one to the righthand side all of the Jpanel.

    Anybody know how its done, help would be great.

    thanks guys & girls

    signing off......


Comments

  • Registered Users Posts: 11,980 ✭✭✭✭Giblet


    Try different layout managers.
    Something like CONTROL.setAlignmentX(CENTER_ALIGNMENT); would work aswell depending on what layout you use.


  • Registered Users Posts: 4,188 ✭✭✭pH


    I thought that a flow layout (center) was the default layout manager, but if not you can try:
    panel.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.CENTER));
    panel.add(button1);
    panel.add(button2);
    panel.add(button3);
    


  • Registered Users Posts: 618 ✭✭✭smithslist


    Sorry I should be more detailed in what I wish to develop, I am creating 6 small JPanels, and I am creating them, one below the other.

    The problem is I can get the Labels (and TxtFields) to be central, with setting the size of each labels and the furthest two from the right I have as JLabel.right,

    But its the height between the top and bottom of each JLabel(or txtfield) that is different on each side within a single jpanel.

    start of jpanel

    label txtfield label txtfield label txtfield


    end of jpanel

    As you can see here with the space between the start - to - label, and the distance of jpanel end - to - label is different

    This is my problem.....

    thanks everyone for their help


  • Registered Users Posts: 919 ✭✭✭timeout


    If you post a section of code showing what you have done then we can see more clearly where you are going wrong.


Advertisement