Reputation: 2673
In my application, I have a layout similar to what is shown below:
@@@@@@@
XXXXXXX***
XXXXXXX***
XXXXXXX***
%%%%%%%
In this layout, X
is a JTable. The other components can remain the same size. Is there a layout or strategy that will have the JTable (X
) resize based on available screen size and have everything else stay on the sides properly?
Thanks.
Upvotes: 2
Views: 469
Reputation: 7142
I am a big fan of JGoodies FormLayout. Here is some sample code of one way to do this with FormLayout.
JPanel panel = new JPanel();
FormLayout layout = new FormLayout("100dlu, 20dlu:grow", "pref, pref, pref");
panel.setLayout(layout);
JTextField t1 = new JTextField();
JTextField t2 = new JTextField();
JTable tb = new JTable();
JScrollPane sp = new JScrollPane();
sp.setViewportView(tb);
CellConstraints cc = new CellConstraints();
panel.add(t1, cc.xy(1, 1));
panel.add(t2, cc.xy(1, 3));
panel.add(sp, cc.xyw(1, 2, 2));
Upvotes: 0
Reputation: 17321
It can also be done with GroupLayout, but it is designed for GUI builders, as it's very verbose. So if you already have existing code, you might not want to try it first.
Upvotes: 0
Reputation: 1074
That looks very much like a BorderLayout to me. Have you tried that?
Upvotes: 5