Results 1 to 5 of 5

Thread: Finding the radio button that have been clicked [*Resolved*]

Threaded View

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Dec 2001
    Posts
    1,331

    Resolved Finding the radio button that have been clicked [*Resolved*]

    Hello,

    I have a user interface using swing. I have 3 radio buttons grouped (Economy, Business, First). I want to find which one the user has clicked. I have grouped the radio buttons and placed them inside a panel. I have added addItemListener to each one. I have used to the code below to print out the radio button that have been clicked. I want to print out either Economy, Business or First, depending on which one the user clicked.

    All this code does is print out a load of rubbish, each time a radio button is clicked. Not sure why.

    VB Code:
    1. public void itemStateChanged(ItemEvent event)
    2.     {
    3.         String item = "";
    4.        
    5.         if ( event.getStateChange() == ItemEvent.SELECTED )
    6.         {  
    7.             item = event.getItem().toString();
    8.                        
    9.             System.out.println("Radio Button: " + item);
    10.         }      
    11.     }

    Thanks in advance,

    Steve
    Last edited by steve_rm; Sep 4th, 2006 at 06:34 AM.
    steve

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width