• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to get the expression through multiple jcomboBox  RSS feed

 
amir asyraf
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have 2 jcombo Box, how  do i actually can link both of it and perform one line expression ?  is there any example where i can refer ? any example code surely help me. 

combo box 1 =  red, black, blue, yellow
combo box 2 = cat, fish, monkey, dog

the output i want is :

red monkey or black dog

thank you,
Capture.PNG
[Thumbnail for Capture.PNG]
jcombobox
 
Dave Tolls
Ranch Foreman
Posts: 3068
37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you tried anything yet?

Have you added an ActionListener to the JButton for example?
 
amir asyraf
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ya, but i still did not find the function/method that i want.

Dave Tolls wrote:Have you tried anything yet?

Have you added an ActionListener to the JButton for example?
 
Dave Tolls
Ranch Foreman
Posts: 3068
37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is no single method that will do what you need.

IN the ActionListener method you will need to read the values selected in the two combo boxes and then print them out wherever it is you need to print them out.

So you know how to get the value out of a JComboBox?
 
Campbell Ritchie
Marshal
Posts: 56599
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch

Maybe you can find the ansewrs in a Tutorial. Here is one: search for combo box or similar and you should find something useful.
 
amir asyraf
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i see, thanks dude.

just wondering how to solve this. let say if my first jcomboBox have value "1", it will print out to "chicken" without using if else. you have an idea ?



Dave Tolls wrote:There is no single method that will do what you need.

IN the ActionListener method you will need to read the values selected in the two combo boxes and then print them out wherever it is you need to print them out.

So you know how to get the value out of a JComboBox?
 
Campbell Ritchie
Marshal
Posts: 56599
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
amir asyraf wrote:i see, thanks dude. . . .
That's a pleasure
. . .
Well, that's not going to work, is it?

Always put a bit of space before { so as to make your indenting clear.
 
Dave Tolls
Ranch Foreman
Posts: 3068
37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm confused now.
Your combo boxes have text in them, so where does the "1" come from?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!