Results 1 to 3 of 3

Thread: ItemListener question

  1. #1

    Thread Starter
    Member
    Join Date
    May 2002
    Location
    AUS
    Posts
    38

    ItemListener question

    I have three radio buttons that are set into a group to enable only 1 selection. I have set itemlisteners to all 3 buttons.

    When the user clicks 1 of the buttons, they are prompted using YES_NO dialog box'asking them to confirm the change'.


    My problem is this: If they decide not to proceed, the newly seleted button becomes the current active choice. How can I prevent this from happening?

    I mean how can I set a radiobutton but without calling the listeners method?
    Last edited by slipper; Mar 28th, 2004 at 04:47 PM.

  2. #2
    Dazed Member
    Join Date
    Oct 1999
    Location
    Ridgefield Park, NJ
    Posts
    3,418
    If the user decides to click no on the dialog i don't think that there is a way of preventing the new button selection to take place. The only thing i could think of would be to change back to the previous button if the user selects no.

  3. #3
    Dazed Member
    Join Date
    Oct 1999
    Location
    Ridgefield Park, NJ
    Posts
    3,418
    Code:
    public void actionPerformed(ActionEvent ae){
          int i  = JOptionPane.showConfirmDialog(jf, "Please confirm!", "Confirm", JOptionPane.YES_NO_OPTION);
          if(i == JOptionPane.NO_OPTION){
            // Need to get back to the previously selected button!
          }     
         }
        }

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