Reputation: 19
is there a way where i can add buttons verically on the left side of a frame and tabbed area in the right using swing?
Upvotes: 1
Views: 1295
Reputation: 324137
Expirement with the different layout managers. And remember you can nest layout managers to achieve your desired effect. The only way to learn how to use them is to try them out. The tutorial has lots of demo code.
Also using a GridLayout in the West may not be as simple as it seems since the buttons size will keep changing as the height of the frame keep changing. So you may need code something like:
JPanel grid = new JPanel( new GridLayout(...) );
grid.add( ... );
JPanel wrapper = new JPanel();
wrapper.add( grid );
frame.add(wrapper, BorderLayout.WEST);
Upvotes: 1
Reputation: 205815
JToolBar
with a VERTICAL
orientation is a flexible alternative, as shown here.
Upvotes: 1
Reputation: 421060
I would suggest using a GridLayout for the left "button-panel" and place this in the WEST
pane of a BorderLayout.
.----------------------------------.
| Border layout |
| _[west]_ __[center]___________ |
| | Grid | | ||
| | Layout | | Tabs... ||
| |--------| | ||
| | btn1 | | ||
| |--------| | ||
| | btn2 | | ||
| |--------| | ||
| | btn3 | | ||
| |--------| | ||
| | btn4 | | ||
| |________| |____________________||
'----------------------------------'
Upvotes: 9
Reputation: 23950
You could play with google's WindowBuilder and play with the various layouts. I think a borderlayout should be fine.
Upvotes: 1