• Post Reply Bookmark Topic Watch Topic
  • New Topic

About JComboBox and JRadioButton

 
Latif Hemid
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi, guys


I made a small program in wich when I select the one of the items in the combobox an image will appeare on the jlabel 1 on the right.
there are 2 JRadioButtons on the buttom of the JFrame and when i click one of the radiobuttons it will display the value of the image on jlabel 2.

when the second radiobutton is clicked, it will display another value about the image on the jlabel 3 .
but the problem is when I select the second item in the combobox it will still display the old value of firts item on jlabel 2 and 3 .

the question is how can I make it come to the default value automatically ( example: 0; ) when i select second item in the combobox.

thanks.
 
Darryl Burke
Bartender
Posts: 5152
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you discovered the Oracle tutorials? There's a section on Handling Events on a Combo Box.
 
Rob Camick
Ranch Hand
Posts: 2699
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
the question is how can I make it come to the default value automatically ( example: 0; ) when i select second item in the combobox.


You need to invoke the code that is executed when you click on the radio button. That is every time you select an item from the combo box you need to do two things:

1) update the image
2) query the radio button to determine which one is selected and then display the data related to that radio button.

Also, quit cross posting questions: http://stackoverflow.com/questions/29677098/about-jcombobox-and-jradiobutton. Its annoying when you spend time answering a question only to find out it was answered somewhere else.
 
Latif Hemid
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also, quit cross posting questions: http://stackoverflow.com/questions/29677098/about-jcombobox-and-jradiobutton. Its annoying when you spend time answering a question only to find out it was answered somewhere else.


Hi,
İ am really sorry for that i did not mean it. i just wanted to get advice as soon as possible be cause of the time difference.
i finally did it.

Thanks everyone in here.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!