aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes setLocation and setBounds are not working for JComboBox Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Reply locked New topic
Author

setLocation and setBounds are not working for JComboBox

john price
Ranch Hand

Joined: Feb 24, 2011
Posts: 495

setLocation and setBounds are not working for JComboBox. All my other code is working perfectly fine though.
At the top of my code is:

I tried this:

and this:

I also tried this:

They all compile and run fine. The JComboBox pops up fine and works fine, just not in the right location.
Please help!


“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” (Mosher's Law of Software Engineering)
“If debugging is the process of removing bugs, then programming must be the process of putting them in.” (Edsger Dijkstra)
Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4530
    
    5

Don't even try to use setLocation/Size/Bounds. Learn to lay out a GUI the correct way.
http://download.oracle.com/javase/tutorial/uiswing/layout/index.html

edit: as you've already been told.
http://www.coderanch.com/t/531941/GUI/java/specify-position-ComboBox

Also, you haven't taken care of following the convention in respect of variable names.

Honestly, if you're not prepared to learn from the responses to your queries, why bother to ask?


luck, db
There are no new questions, but there may be new answers.
john price
Ranch Hand

Joined: Feb 24, 2011
Posts: 495

I added:

to my code.
Result: blank screen

EDIT: I figured it out
Had to do:

Had to add to frame, not panel...Thank you!
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19672
    
  18

Please UseOneThreadPerQuestion. This is a continuation of this thread.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
wood burning stoves
 
subject: setLocation and setBounds are not working for JComboBox