• 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:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
Bartenders:
  • Carey Brown
  • Tim Holloway
  • Joe Ess

show second combobox without clik on buttom  RSS feed

 
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi
i want diplay a second combobox but when i select an item from the first combobox the second will be show
becaus i do now when i select item from the first combobox i must clik on buttom to show the second
so i want show this last without clik on buttom just when i select from the second it must be displayed
thank you
 
Marshal
Posts: 4455
284
Clojure IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've read this a few times now and it's still not making any sense to me. Can you try to explain your problem again in much simpler terms. Perhaps with an example of what you have and show what currently happens against what you intend to happen.
 
Bartender
Posts: 5167
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can add an ActionListener to a JComboBox. Read the API and follow the link to the tutorial on How to Use Combo Boxes. Another section in the same tutorial will show How to Write an ActionListener.

edit: Note that after adding a component to an already visible GUI you will need to revalidate its container hierarchy. It may be better design to show the second combo box at launch, but to keep it disabled until a selection is made in the first combo.
 
Bartender
Posts: 10575
66
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

wafa khan wrote:i want diplay a second combobox but when i select an item from the first combobox the second will be show
becaus i do now when i select item from the first combobox i must clik on buttom to show the second
so i want show this last without clik on buttom just when i select from the second it must be displayed


Like Tim, I'm a bit mystified by your 'requirement'. It also sounds like "micro-optimization" to me (although I'm no GUI expert).

My advice: Read the TellTheDetails (←click) page, and come back with a better question.

Otherwise: Get your GUI working and worry about trivial stuff like this when you're simply adding the 'bells and whistles' (assuming you have time).

Alternative 2: This sounds to me like the sort of thing that a "Menu" might do; although, like I said, I'm no GUI expert.

Winston
 
wafa khan
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
well im sorry

i have 2 combobox the first it's for the databses do diplay all of databases in this combo
and i clik on bottom to show the second combobox which he displays the tables of the database selected

So what i want it's without clicked on button just when i select database from the first combo the second combo will automaticlly been diplayed
 
wafa khan
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i do that but the second combobox show when i run the project

 
Winston Gutkowski
Bartender
Posts: 10575
66
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

wafa khan wrote:well im sorry

i have 2 combobox the first it's for the databses do diplay all of databases in this combo
and i clik on bottom to show the second combobox which he displays the tables of the database selected

So what i want it's without clicked on button just when i select database from the first combo the second combo will automaticlly been diplayed


And I say again: this sounds like "optimization".

Does your entire GUI actually work right now?

If not, and you can get it to work with a mouse-click, leave this until you have time to deal with it; because it sounds like a trivial "nice-to-have" thing compared to the overall process.

Winston
 
Tim Cooke
Marshal
Posts: 4455
284
Clojure IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So we're talking about Swing JComboBox's here? That wasn't clear from your original post. I was thinking about a web <select> combo box.

Unfortunately it's been far too long since I've done any Swing development for my knowledge to be useful so I'm out.
 
wafa khan
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Okey i do it thank you all of you
have a nice day
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!