Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Newbie, Absolute Layout Question  RSS feed

 
Dave Guenthner
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello. I am new to Java and have installed Sun One Studio 4 Update 1 to help with experimenting with GUI forms. I have read several explanations regarding the layouts. I have found them to be difficult to construct compared to VB, until I found the absolute layout. It was easy to construct the GUI the way I wanted. Unfortunately, I have read serveral articles that strongly stated that absolute layout should be used for testing purposes only and that it may not work well?? Can someone help with any advise, is it that the standard layouts just take time to learn to work with or is JAVA just difficult to work with as far as GUI is concerned.
Thanks in advance,
Dave
 
Paul Stevens
Ranch Hand
Posts: 2823
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Depends on your point of view. I don't have any problems with the layouts. There isn't a great gui building tool like VB but if you know how to use them they aren't a problem.
The problem with the absolute layout is resizing. You have to code your own or lock the size of the window. If it is just a pop-up dialog this may not be a problem, but for a larger gui it is.
The layouts themselves aren't really that difficult to learn. It is the combinations that are sometimes needed that take a little time. You may need multiple panels with multiple layouts to get the desired effect.
If you plan on doing java guis, learn the layouts.
 
Chantal Ackermann
Ranch Hand
Posts: 508
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
some suggestion where to start:
when I started with Swing I found the layouts quite complicated especially the GridBagLayout and the GridBagConstraints. I didn't understand what some constants in the GridBagConstraints were for and how to combine and use any of them. But in the tutorial you have some sample code and in the internet you certainly find even more samples, so you can learn through reusing these samples.
Now, when I design a GUI, I end up with GridBagLayout most of the time. it is the most powerful and most flexible layout manager. BorderLayout may be easier but if you need to change something you reach its limits quite fast.
Moreover, with GridBagLayout you can create the same layouts as with any of the other layouts, but vice versa you will always need to combine layouts or use lots of panels.
Learning GridBagLayout will give you the means to create complex guis, and if you understand this Layout, you will understand the others as well.
Chantal
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!