• Post Reply Bookmark Topic Watch Topic
  • New Topic

switch images on combo box select  RSS feed

 
mohd sherrez
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi may I ask is it possible to switch images (on jlabel)on combobox item select. I
If (combobox.selecteditem = value)
{
SetIcon (resource)//I'm using the default auto generated code used by eclipse when we set an icon for a jlabel in the gui
}
 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
mohd sherrez wrote:Hi may I ask is it possible to switch images (on jlabel)

Sure! Check out the JLabel API docs for a method which will let you do this.

In pseudo code
1) Listen to combo box change
2) Identify which image is required
3) Use the above mentioned method to set the proper image
 
Rob Camick
Ranch Hand
Posts: 2801
15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Read the section from the Swing tutorial on How to Use Combo Boxes for a working example.
 
mohd sherrez
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi what's the action listener I have to use for the combobox popmenu becomes invisible or action performed to allow switching of image the combobox api is confusing.
Secondly will the jlabel icon still switch if I have a preexisting icon set
 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
mohd sherrez wrote:Hi what's the action listener I have to use for the combobox popmenu becomes invisible or action performed to allow switching of image the combobox api is confusing.

Did you check out the link Rob provided? It has a relevant section on listening to changes

mohd sherrez wrote:
Secondly will the jlabel icon still switch if I have a preexisting icon set

What happened when you tried it out?
 
mohd sherrez
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi I can't find that part is it in handling events of combobox?
 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
 
mohd sherrez
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
THANKS guys it all works You guys have taught me to read apis ! thanks so much!
may god bless you
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!