• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Not understanding layouts in java?

 
Ranch Hand
Posts: 51
Eclipse IDE Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Lately I have been testing different layout managers in java and none of them seem to make any sense to me. I understand the point of a layout manager, but I feel I can't get any of them to work properly. I'm coming from basic languages where you specified the position you wanted an element to go. I would like a layout manager that gives me complete control of my GUI without it being too difficult. Any tutorials or videos would be greatly appreciated, I have already looked at the Oracle help docs but it still isn't helping me.
 
Rancher
Posts: 3324
32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Start with the Swing tutorial. It has a section on using Layout Managers. Rarely would you use a single layout manager. Instead you would logically divide you GUI up into sub panels each which can use a different layout manager.

I'm coming from basic languages where you specified the position you wanted an element to go



The wrong approach when using Java. Layout managers do more than just position components on the screen.
 
Sheriff
Posts: 3063
12
Mac IntelliJ IDE Python VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You certainly can set the layout manager to null, and then specify the absolute positions of everything yourself. That doesn't really seem easier to me. Also, if you resize the window, then you have to write listeners to reposition everything to fit into the new space. That's really not fun. Could you be more specific about what's giving you trouble? Are some layout managers easier for you than others?
 
Bartender
Posts: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
For learning layout managers, the relevant section would be http://docs.oracle.com/javase/tutorial/uiswing/layout/index.html
Like Rob rightly said, the correct approach would be mix and match and nesting layouts. I have always thought of layouts as a sort of reverse jig saw puzzle. I know the complete picture (the UI design) and I try to break it down to known patterns (layouts)
I would suggest, you check out the provided link and identify what all patterns are available to you out of the box and then try to work your way back from your UI design. In case you get stuck you can always share your problem details here and we can help point you in the right direction.
 
John Corkrend
Ranch Hand
Posts: 51
Eclipse IDE Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok well I will post back when I have a problem with a layout manager. I get frustrated when trying to implement one because I don't fully understand how to and exactly what to do. Thanks for the help.
 
Farmers know to never drive a tractor near a honey locust tree. But a tiny ad is okay:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic