Results 1 to 1 of 1
- 05-02-2014, 07:55 PM #1Senior Member
- Join Date
- Mar 2014
- Rep Power
Components (JPanels) appear extra small in GridBagLayout.
I added a JPanel to the CENTER position of a JFrame, and now I am adding two panels to that panel. I want the right panel to be double the width of the left panel, (and also for practicing the GridBagLayout), and I also want the panels to expand proportionally when the window is expanded, so I am using GridBagLayout.
The problem is that the panels turn out to be very very small and in the centre of the page, as you can see in the image. I need to fix this.
I am posting the part of the code in which I have set the layout and set the constraints. Please point out which GridBagLayout constraints I might have used wrong, or which should I use, so that both the panels cover up the entire parent panel such that the iDetailsPanel is double the size of the iListPanel..
//Set Layout setLayout(new GridBagLayout()); GridBagConstraints c= new GridBagConstraints(); //Set Layout constraints of components and add them to the MainPanel c.gridx=0; c.gridy=0; c.weightx=0.5; c.insets= new Insets(5,5,5,5); c.fill=GridBagConstraints.BOTH; add(iListPanel); iListPanel.setBorder(BorderFactory.createTitledBorder("Check") ); GridBagConstraints c1= new GridBagConstraints(); c.gridx=1; c.gridy=0; c.weightx=1; c.insets= new Insets(5,5,5,5); c.fill=GridBagConstraints.BOTH; add(iDetailsPanel); iDetailsPanel.setBorder(BorderFactory.createTitledBorder("Check"));
Last edited by Zarah; 05-02-2014 at 08:08 PM.
- By ShadowWalker in forum New To JavaReplies: 2Last Post: 01-02-2014, 09:00 PM
- By Serpenthelm in forum AWT / SwingReplies: 3Last Post: 01-05-2012, 07:52 PM
- By ToXSiK in forum AWT / SwingReplies: 1Last Post: 05-12-2011, 05:09 AM
- By peterhabe in forum New To JavaReplies: 4Last Post: 09-19-2010, 11:13 PM
- By ze snow in forum New To JavaReplies: 1Last Post: 02-27-2010, 03:22 PM