Hi everyone, I have a question about laying out some swing components.
Say, I have a JPanel which contains a JLabel and a JTextField. I want JLabel to be drawn on the left-most side of JPanel, and JTextField to be drawn on the right-most side of JPanel. I tried using BoxLayout and Horizontal Glues, but I couldn't make it work. Can somebody explain how this should be done? And by the way, I also should be able to set the JTextField's size, which will grow from right to left.
EDIT: Here is my class, it's pretty simple.
public class TextField extends JPanel {
private JLabel label;
private JTextField textField;
public TextField(String labelText){
this.label = new JLabel(labelText);
this.textField = new JTextField("");
Box horizontalBox = Box.createHorizontalBox();
horizontalBox.add(label);
horizontalBox.add(Box.createHorizontalGlue());
horizontalBox.add(textField);
add(horizontalBox);
}
}