Bookmark Topic Watch Topic
  • New Topic

setLocation and setBounds are not working for JComboBox

 
john price
Ranch Hand
Posts: 495
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Report post to moderator
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!
 
Darryl Burke
Bartender
Posts: 5133
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Report post to moderator
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?
 
john price
Ranch Hand
Posts: 495
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Report post to moderator
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
Pie
Posts: 20559
57
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Report post to moderator
Please UseOneThreadPerQuestion. This is a continuation of this thread.
 
    Bookmark Topic Watch Topic
  • New Topic