• 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

A big GUI question....

 
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm not sure if this is exactly a question...it's pretty big.

Anyways, I'm designing a GUI interface; my previous experience has been with more GUI-based languages, such as VB and RealBasic. I'm having some trouble getting my interface to look exactly how I want it. Right now all I've got is a FlowLayout() and that is just not doing it. What are some basic methods that I could use to order all of the buttons/JTextFields/drop-down menus/whatever in my JFrame? I know this isn't very specific...sorry!
 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
FlowLayout puts everything in a line, so yeah, that's only going to get you so far!

There are two basic ways you can go: GridBagLayout, or nested simple layouts.

The GridBagLayout layout manager can do anything. It's really complicated, though, and you can spend forever and a day getting everything just so. But one GridBagLayout could be used to layout dozens of components in a single container in an almost arbitrarily complex arrangement.

The other way to go is to use many nested containers and multiple layout managers. Use one JPanel with a row of buttons in it using a FlowLayout. Add that JPanel to the bottom of a JFrame which uses the BorderLayout. In the center of that JFrame, add another JPanel using a GridLayout. And so on. You can build up complex arrangements like this one piece at a time.

Personally, I do the latter. I like building things up incrementally.

Finally, there are indeed IDEs with GUI-builders that let you draw your interface. These are generally frowned upon by Swing afficianados, but they do exist.
 
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Moving this to the Swing / JFC / AWT forum, where they love to get messy with this GUI stuff...
 
Ranch Hand
Posts: 820
IntelliJ IDE VI Editor Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have to say that IntelliJ IDEA 4.0 has a GUI builder that allows me to bypass the layouts and get everything "just so" by clicking and dragging. It was easy to learn and allows you to add custom controls for easy reuse.

The drawback, of course, is that if you open one of my .java files in a text editor, it isn't very pretty, but I have saved weeks and probably years off of my life by using the GUI builder and that makes it worth it to me.
 
rubbery bacon. rubbery tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic