| | |
Layout Manager problem with Swing
Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Sep 2008
Posts: 1,597
Reputation:
Solved Threads: 202
I'm using netbeans and I have a problem. I'm using a card layout to flip between multiple windows. Two of these windows are wider than the others, and this cannot really be helped. Ideally, it would be best to design each window so that they are all the same size, but it is impossible in this case, due to the types of information. Anyway, I can't figure out how to make them resize themselves at runtime based on which window is selected. I have the following hierarchy:
JFrame
JTabbedPane
JPanel 1 (as one of the tabs, this JPanel contains the card layout)
JPanel 2 (this is inside JPanel 1, and contains the combo box which decides what window to flip to)
JPanel (this is inside JPanel 1, and contains the windows that are flipped between)
I've tried explicitly setting the size, starting with the topmost component (the JFrame), then resizing each of the things underneath. No luck, it just ignores me and does not change the size of anything except the JFrame.
Edit:
Yeah, I don't know what I'm going to do. Since the top level container is the only thing stopping the lower ones from resizing, resizing from the top down should be working. So I guess it's the layout manager which is stopping things from being resized. Hm.
JFrame
JTabbedPane
JPanel 1 (as one of the tabs, this JPanel contains the card layout)
JPanel 2 (this is inside JPanel 1, and contains the combo box which decides what window to flip to)
JPanel (this is inside JPanel 1, and contains the windows that are flipped between)
I've tried explicitly setting the size, starting with the topmost component (the JFrame), then resizing each of the things underneath. No luck, it just ignores me and does not change the size of anything except the JFrame.
Edit:
Yeah, I don't know what I'm going to do. Since the top level container is the only thing stopping the lower ones from resizing, resizing from the top down should be working. So I guess it's the layout manager which is stopping things from being resized. Hm.
Last edited by BestJewSinceJC; Apr 26th, 2009 at 4:57 pm.
![]() |
Similar Threads
- using methods in different classes. (Java)
- Help with automatic update problem and more (Viruses, Spyware and other Nasties)
- Help needed passing socket info to JTextArea (Java)
- projects window (Java)
- Hello there! (Java)
- JTable help! (Java)
Other Threads in the Java Forum
- Previous Thread: Student Survey Assignment
- Next Thread: Datasets
| Thread Tools | Search this Thread |
2dgraphics android api apple applet application arguments array arrays automation banking binary binarytree bluetooth capture chat chatprogramusingobjects class classes client code color component count database derby design eclipse eclipsedevelopment encryption error event exception fractal game givemetehcodez graphics gridlayout gui html ide if_statement image input integer interface j2me java javadesktopapplications javaprojects jlabel jni jpanel julia keyword linux list loop macintosh map method methods midlethttpconnection mobile netbeans newbie object os print printing problem producer program programming project projectideas read recursion reference replaysolutions ria scanner screen server set size sms sort sourcelabs sql stop string swing threads transforms tree ui unicode validation windows






