This week's book giveaway is in the Cloud/Virtualization forum.
We're giving away four copies of Learning OpenStack Networking: Build a solid foundation in virtual networking technologies for OpenStack-based clouds and have James Denton on-line!
See this thread for details.
Win a copy of Learning OpenStack Networking: Build a solid foundation in virtual networking technologies for OpenStack-based clouds this week in the Cloud/Virtualization forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

Simple Swing  RSS feed

 
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does anyone know the method I need to call on my objects (ComboBoxes and Labels) to set their position in the application GUI? Thanks!
Edit: Also, what would the code be to exit my application that I can put in an event listener? Thanks again!
[ April 16, 2002: Message edited by: Chris Stewart ]
 
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well if you aren't using a layout manager you'll need to call the setBounds() method on each component to set their size and location. Of course if you're using a layout manager then how you position the components will vary depending on the layout you're using.
And to exit your program you can use the System.exit method.
Jeff
 
Chris Stewart
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the exit method!
About the layout manager. I'm really not too sure what you mean. I'm setting the layout to FlowLayout.

I then go on to create my labels, comboboxes and buttons. I thought I would need to use setBounds but I wasn't sure. Do I need to use that?
 
Ranch Hand
Posts: 2823
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you allow the Layout Manager to handle positioning, you don't need to be concerned with it. It will determine where to place the component.
 
Chris Stewart
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is there anyway I can do it myself? All of my comboboxes and labels are just lined up beside each other. It really looks terrible.
 
Jeff SmithX
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As I don't know how exacly you're trying to get the components lined up it's difficult to suggest a layout to use, but take a look at the javadoc for LayoutManager and LayoutManager2 and look through the lists of implementing classes. I'm sure there's one there that can do what you need. I personally use the GridBagLayout for nearly everything as it gives a great deal of control.
Jeff
 
Chris Stewart
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok, I changed it to use GridLayout for the manager. Making some progress now.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!