title: Clear a JLabel with a Jbutton
body: <p>I am actually a beginner in Java Programming (on eclipse and without netbeans), and want to clear a JLabel presents in a JFrame by clicking a JButton without removing the JButton present at the top of this frame.</p>
  
  <pre><code>import java.awt.Color;
  import java.awt.Container;
  import java.awt.event.ActionEvent;
  import java.awt.event.ActionListener;
  import java.awt.event.WindowAdapter;
  import java.awt.event.WindowEvent;
  import javax.swing.JButton;
  import javax.swing.JFrame;
  import javax.swing.JPanel;
  import javax.swing.JOptionPane;
  import java.awt.*;
  import java.awt.BorderLayout;
  import java.awt.event.KeyEvent;
  import javax.swing.BoundedRangeModel;
  import javax.swing.JFrame;
  import javax.swing.JLabel;
  import javax.swing.JPanel;
  import javax.swing.JTextField;
  
  public class ButtonTest extends JPanel implements ActionListener {
    private JButton ouvrirButton = new JButton("Ouvrir");
    private JButton retirerButton = new JButton("Retirer");
    private JButton ajouterButton = new JButton("Ajouter");
  
  public ButtonTest() {
    add(ouvrirButton);
    add(retirerButton);
    add(ajouterButton);
  
  ouvrirButton.addActionListener(this);
  retirerButton.addActionListener(this);
  ajouterButton.addActionListener(this);}
  
  public void actionPerformed(ActionEvent evt) {
   Object source = evt.getSource();
   Color color = getBackground();
  
  // ACTION Button "OUVRIR"
  // I WANT TO REMOVE THIS JLABEL TEXT WHEN I CLICK FOR EXEMPLE ON
  // OR "RETIRER"
  
  if (source == ouvrirButton)
  { 
      color = Color.yellow;
      JLabel lab1 = new JLabel("Text", JLabel.LEFT);
      setLayout(new FlowLayout()); 
      add(lab1 = new JLabel("INVENTAIRE : "));
      lab1.setBounds(20, 15, 500, 100);
  }
  else if (source == retirerButton)
          color = Color.red;
  else if (source == ajouterButton)
      color = Color.red;
  setBackground(color);
  repaint();
  }
  
  // The main
  
   public static void main(String[] args) {
    // NOM DE LA FENETRE
    JFrame frame = new JFrame("Programme ");
  
  frame.addWindowListener(new WindowAdapter() {
    public void windowClosing(WindowEvent e) {
      System.exit(0);
    }
  });
  
  Container contentPane = frame.getContentPane();
  contentPane.add(new ButtonTest());
  frame.setVisible(true);
  frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);    
  frame.setSize(1300, 700);
  frame.setVisible(true);    
  }
  }
  </code></pre>
  
  <p>I tried   .setText("")  but it doesn't work... Please help me !</p>