File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Best layout tutorials?

 
Sandeep Swaminathan
Ranch Hand
Posts: 52
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well well when it comes to layout I'm always confused which one to use! People say GRIDBAGLAYOUT is the best but the examples used are so damn confusing that I'm not able to implement them
Is there a better example for gridbaglayout? Or shall I use any other layout? I have developed a code and there's a screenshot attached too which is what the output is supposed to look! Suggest me friends

Thanks !!
 
Campbell Ritchie
Sheriff
Pie
Posts: 47281
52
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you are using GridBag you need a trip to Cai Horstmann's website (or the appopriate chapter of his book) to learn about his GBC class. It makes using GridBag much easier. He quotes this tutorial, but some people think it's a spoof.

Google for MigLayout; I have never used it, but I have heard it is easier to use than GridBag.
 
pete stein
Bartender
Posts: 1561
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I know many (myself included) who avoid using GridBagLayout unless absolutely necessary. Most layouts can be set up by using the other managers and by nesting JPanels.

By the way, I couldn't find your link.

Edit: also,

  • You might want to avoid calling JFrame#show() as it has been deprecated. Instead call JFrame#setVisible(true);.
  • You'll want to call pack(); before setVisible(true) as this will tell your layout managers to do their laying out.
  • You'll only want to call these methods after you've added your widgets into your GUI. If you do it otherwise (like I see now), your GUI will be blank until it is manually resized.
  • Avoid using setSize(...) but instead use setPreferredSize(....), and use it relatively sparingly. Most layout managers respect the preferred size, not the size.
  •  
    I agree. Here's the link: http://aspose.com/file-tools
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic