|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now! |
|
#1
|
||||
|
||||
|
Swing - Best way of using Layouts
What is the best way to use layouts? for example.. I want to layout two buttons.. one next to each other.. (top/left area) with a space between them. Been reading about boxlaouts/cardlayouts etc.. cant seem to find the one that fits.
__________________
IE QUOTE | PHP Manual | Google | C/C++ Compiler | Linux Tutorials | General Stuff Game Dev |
|
#2
|
||||
|
||||
|
In my experience the best way is to look at the Visual Guide to Layout Managers and read the descriptions.
For your specific problem I'd suggest a FlowLayout. Or maybe a GridBagLayout or a SpringLayout if you have a few other components and don't want to nest panels... Definitely not CardLayout, that does something completely different. BoxLayout are very specific in their use. You use it if you need all the cells to have the same dimensions. It could work in your case but is probably isn't what you are looking for...
__________________
- Hugh of Borg The first thing young borg are taught: Keep away from Microsoft software! |
|
#3
|
||||
|
||||
|
The best way to use layouts is to use more than one. Split up the job between different panels and give each it's own layout.
But yea I'd probably opt for just a flow layout.
__________________
The day I get my hands on the cookbook it's all over. -nicky |
|
#4
|
||
|
The trick is that some layout managers respect the size of your widget, but do not guarantee a correct overall layout. Others guarantee a correct overall layout, but your widgets will expand to fill the entire panel. The only time I use one layout is on the simplest page.
__________________
A -> B: Ride. The road to enlightenment is more fun on two wheels. The recent fuel price increase has had an interesting side effect. Many of the people that used to always say to me "You shouldn't ride a motorcycle, they're dangerous" are now saying "So, what kind of mileage do you get?"... Last edited by mrider : May 6th, 2008 at 10:01 AM. Reason: English mrider, English... |
|
#5
|
||||
|
||||
|
Quote:
And others will respect the size of your widget and guarantee a correct overall layout but are so god awful complicated to use that you might as well not bother. I'm looking at you GridBag and Spring Layout. |
|
#6
|
||||
|
||||
|
|
|
#7
|
||||
|
||||
|
Pretty much. I like to use border layout for the parent frame.
|
![]() |
| Viewing: Dev Shed Forums > Programming Languages > Java Help > Swing - Best way of using Layouts |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|