Results 1 to 4 of 4
Thread: Java Layout not working ?!
- 03-14-2012, 10:58 PM #1
Member
- Join Date
- Mar 2012
- Posts
- 2
- Rep Power
- 0
Java Layout not working ?!
Hi all!
I'm new to java GUI and I ran into a problem that I can't find a solution.
My app is split into 3 parts (NORTH,CENTER,SOUTH.... You knew that already right?)
But on my north I want to have 2 JPanels side by side.
Now that seems to be impossible! I can't get it to work.
Here is my code.
The thing here is that panel1 is smaller than panel 2, and they are both side by side but not at the left corner.Java Code:JPanel pNorth = new JPanel( new GridBagLayout() ); GridBagConstraints c = new GridBagConstraints(); setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); setTitle("Google Static Maps"); setIconImage(null); setLocation(250,300); setSize(700,500); add(pNorth, BorderLayout.NORTH); c.insets = new Insets(10,10,10,10); //c.gridx = 10; //c.gridy = 1; pNorth.add(panel1, c); pNorth.add(panel1,c); panel1.setBorder(new CompoundBorder( new TitledBorder("Configure the inputs to Google Static Maps"), Borders.DLU2_BORDER)); panel2.setBorder(new CompoundBorder( new TitledBorder("Configure the inputs to Google Static Maps"), Borders.DLU2_BORDER)); }
How can I have my panel1 on the left corner and Panel2 right beside it.
What I did was create a Panel called pNorth and I set that to North, then I added both panels inside of it. Should I do it like that or is there a better way?
Thank you!
-
Re: Java Layout not working ?!
- 03-15-2012, 12:19 AM #3
Member
- Join Date
- Mar 2012
- Posts
- 2
- Rep Power
- 0
Re: Java Layout not working ?!
But how can I get the inner JPanel to be at the left of the parent frame?
Thank you!
- 03-15-2012, 05:01 AM #4
Re: Java Layout not working ?!
Moved from New to Java.
Lesson: Laying Out Components Within a Container (The Java™ Tutorials > Creating a GUI With JFC/Swing)
dbWhy do they call it rush hour when nothing moves? - Robin Williams
Similar Threads
-
Grid Layout change layout alignment of control s
By rellicott in forum SWT / JFaceReplies: 1Last Post: 02-13-2012, 05:11 PM -
GUI layout not working
By jobud9 in forum New To JavaReplies: 4Last Post: 01-15-2012, 04:27 AM -
My Second Layout is not working(Tapestry 5)
By yuzi123 in forum Web FrameworksReplies: 0Last Post: 11-25-2011, 07:30 AM -
Java mail problem(working in intranet,but not working in iternet)
By sundarjothi in forum Advanced JavaReplies: 8Last Post: 05-28-2008, 07:00 AM -
Java GUI layout
By nick2price in forum New To JavaReplies: 2Last Post: 05-27-2008, 09:42 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks