Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

JButton, how to use if statement

807598Aug 15 2006 — edited Aug 15 2006
just a quick question,

i'm making a GUI program to respond to a click of abutton,
i get it show me a window with all the buttons and labels, but i cannot get it to give me different output using the same listener.
String button = "";
if( paperButton.isSelected() ) button = "paper";
else if( rockButton.isSelected() ) button = "rock";
else if( scissorsButton.isSelected() ) button = "scissors";
else button = "error";
it always gives me "error" here, i'm i using the wrong method?
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 12 2006
Added on Aug 15 2006
19 comments
3,064 views