shragi
asked on
how to resize the panel within a jFrame automatically
I am having a JFrame and JPanel.
JPanel is having GridBagLayout(). within the panel I have a button and a JScrollPane and JScrollPane is having table.
I filled the JFrame with JPanel using jframe.setContentPane(jpan e).
When I increase or decrease the size of the jframe window its components i.e. jpane is remaining in the middle of the window but it's size is not varying.
So when i increase the size of the jframe window how should I make the jpane to increase its size.
JPanel is having GridBagLayout(). within the panel I have a button and a JScrollPane and JScrollPane is having table.
I filled the JFrame with JPanel using jframe.setContentPane(jpan
When I increase or decrease the size of the jframe window its components i.e. jpane is remaining in the middle of the window but it's size is not varying.
So when i increase the size of the jframe window how should I make the jpane to increase its size.
ASKER
I am still have gridbaglayout for the panel. I cannot have border layout since I need add several buttons of varying sizes at specified positions.
I made the frame to have borderlayout and added the panel to it like this:
frame.setLayout(new BorderLayout());
frame.add(panel);
So when I increase the size of the frame , table and buttons that are added to the panel are remaining in the center.
What should I change so that table and buttons vary their size when frame size is increased with panel still having gridbaglayout.
a LOOONG time ago, I used a percent layout for such a thing
ASKER
So cant I have an automatic resize using gridbaglayout?
Seems not. http://segal.org/java/Resizing/index.html
Much more here: http://www.google.com/search?q=gridbaglayout+resizing+panel
Much more here: http://www.google.com/search?q=gridbaglayout+resizing+panel
ASKER
i am using windows 7
Try flowlayout
ASKER
if it is not possible with the gridbaglayout then I will try other layout options, otherwise I want to use gridbaglayout
have a look here. I no longer do applet stuff
Much more here: http://www.google.com/search?q=gridbaglayout+resizing+panel
Much more here: http://www.google.com/search?q=gridbaglayout+resizing+panel
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Hmm so why was that supposed to be so hard?
and does it work on a Mac?
and does it work on a Mac?
Here is an example, showing the elements you described with the table resizing as the JFrame resizes. It all depends on the exact layouts that you use and how you use them.
When you add a component to another component its best to set the BorderLayout and simply add it, that will make the child component take up the complete parent component.
Open in new window