JTextField layout control
From: steven (yu271637_at_yorku.ca)
Date: 08/25/04
- Next message: Tor Iver Wilhelmsen: "Re: Slow and ugly Java GUIs are programmers' fault"
- Previous message: Reinhard Engels: "textHighlight on os x turns gray"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 25 Aug 2004 13:31:37 -0700
Hi,
I try to arrange several JTextField components in Box container. Below is my code.
private static void addTextField(String text, Container container) {
Box box = Box.createVerticalBox();
JLabel label = new JLabel(text);
JPanel panel = new JPanel();
JTextField textfd = new JTextField(10);
panel.add(textfd);
label.setLabelFor(textfd);
box.add(label);
box.add(panel);
container.add(box);
}
.
.
.
Box box = Box.createVerticalBox();
for(int i = 0; i < 3; i++){
addTextField(" test " + i, box);
}
The result is the JTextField is far away from the label. like the demo below:
test0
----------
| |
----------
I have no idea how to control the size of the JTextField and the location.
Any suggestion?
Steven
- Next message: Tor Iver Wilhelmsen: "Re: Slow and ugly Java GUIs are programmers' fault"
- Previous message: Reinhard Engels: "textHighlight on os x turns gray"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|
|