title: Why won't my .isSelected() method work?
body: <p>Well what i'm trying to do is change the text of the JRadioButton's when they're selected, i got them to change the color. I know I can do it by putting the code to change the text inside the dedicated event handling method specific to each button, but how do I do it so that I use A DIFFERENT event handling method that just changes the buttons? I already created one but it doesn't work, here's the code:</p>
  
  <pre><code>import javax.swing.*;
  import java.awt.*;
  import java.awt.event.ActionEvent;
  import java.awt.event.ActionListener;
  
  
  public class LessonTwenty extends JFrame implements ActionListener{
  
  JRadioButton b1,b2;
  JTextArea t1;
  JScrollPane s1;
  JPanel jp = new JPanel();
  
  public LessonTwenty()
  {
  
  
       b1= new JRadioButton("green"); 
      b1.addActionListener(new ActionListener() {
  
          public void actionPerformed(ActionEvent e) {
  
              jp.setBackground(Color.GREEN);
          }
        });
       b2= new JRadioButton("red"); 
          b2.addActionListener(new ActionListener() {
  
              public void actionPerformed(ActionEvent e) {
  
                  jp.setBackground(Color.RED);
              }
            });
  
  
          //Method to change the text of the JRadion Buttons, what i'm trying to make work
             new ActionListener() {
  
              public void actionPerformed(ActionEvent e) {
  
                   if(b1.isSelected()){
                          b1.setText("Welcome");
                      }
                      else if(b2.isSelected()){
                          b2.setText("Hello");
                      }
              }
            };
  
  
  
  
  
      jp.add(b1);
      jp.add(b2);
      this.add(jp);
  
      setTitle("Card");  
      setSize(700,500);
      setLocationRelativeTo(null);
      setDefaultCloseOperation(EXIT_ON_CLOSE);
      setVisible(true);
  }
  
  
  public static void main(String [ ] args){
  
  
      new LessonTwenty();
  
  
  }
  
  
  @Override
  public void actionPerformed(ActionEvent e) {
  
  
  }
  
  }
  </code></pre>