is there a way where i can add buttons verically on the left side of a fr开发者_运维百科ame and tabbed area in the right using swing?
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 | | ||
| |________| |____________________||
'----------------------------------'
You could play with google's WindowBuilder and play with the various layouts. I think a borderlayout should be fine.
JToolBar
with a VERTICAL
orientation is a flexible alternative, as shown here.
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);
精彩评论