| Author |
Simple Swing
|
Chris Stewart
Ranch Hand
Joined: Sep 29, 2001
Posts: 124
|
|
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 ]
|
 |
Jeff Smith
Ranch Hand
Joined: May 04, 2001
Posts: 50
|
|
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
Joined: Sep 29, 2001
Posts: 124
|
|
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?
|
 |
Paul Stevens
Ranch Hand
Joined: May 17, 2001
Posts: 2823
|
|
|
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
Joined: Sep 29, 2001
Posts: 124
|
|
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 Smith
Ranch Hand
Joined: May 04, 2001
Posts: 50
|
|
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
Joined: Sep 29, 2001
Posts: 124
|
|
Ok, I changed it to use GridLayout for the manager. Making some progress now.
|
 |
 |
|
|
subject: Simple Swing
|
|
|