Author
JPanel and JTextfield not aligning correctly..
Michael Raymond Jr.
Ranch Hand
Joined: May 16, 2005
Posts: 178
Below is part of the code i'm trying to get working...well, it works and compiles, but I can't get it to display how I want it to. Basically, it's a rectangular box with two jlabels and 2 Jtextfields like so: File Name: [ ] Folder name: [ ] Above is how I want it to appear, but instead it's appearing like: File Name: [ ] Folder name: [ ] Total dorkyness....there's probably a layout mnger, but I can't find a way to fix this. Any help would be great! {code}: JPanel panel = new JPanel (); panel.setPreferredSize(new Dimension(500, 200)); //for first row of frame JLabel searchtext = new JLabel ("File Name:", SwingConstants.LEFT); JTextField searchfiles = new JTextField (20); panel.add(searchtext); panel.add(searchfiles); //second row of frame JLabel foldername = new JLabel ("Folder Name:", SwingConstants.LEFT); JTextField createfolder = new JTextField (20); panel.add(foldername); panel.add(createfolder); {code end}
Scooby Snacks for everyone...<br /> <br />SCJA, SCJP 1.4
Michael Dunn
Ranch Hand
Joined: Jun 09, 2003
Posts: 4632
posted May 16, 2005 17:48:00
0
see if this does what you want
Michael Raymond Jr.
Ranch Hand
Joined: May 16, 2005
Posts: 178
cool dude... i plugged in the layout manager (right?) 'gridlayout' and it worked...however, I had to remove: "panel.setPreferredSize(new Dimension(500, 200));" that(above) was screwing everything up. another question... Where on Java's API list can I find these layout managers for swing??? I'm pretty sure they are not listed under javax.swing.* http://java.sun.com/j2se/1.5.0/docs/api/ Thanks!
Michael Dunn
Ranch Hand
Joined: Jun 09, 2003
Posts: 4632
posted May 16, 2005 18:17:00
0
this might be a better link for you http://java.sun.com/developer/onlineTraining/GUI/AWTLayoutMgr/shortcourse.html
subject: JPanel and JTextfield not aligning correctly..