通过一个JButton的鼠标事件,往JPanel中依次添加若干个JLabel.代码如下。
现在我想实现的功能是:使JButton的鼠标事件能自动覆盖之前产生的JLabel。请赐教,在线等。急!!!!!!
import   java.awt.*;
 import   java.awt.event.*;
 import   javax.swing.*;
 import   javax.swing.event.*; public   class   tables   implements   ActionListener
 { String[]   BigProblem={"big1","big2"};
 String[]   problem={"1","2","3","4","5","6","7","8","9","10"}; JFrame   aWindow=null;
 JCheckBox[]   checkBox;
 JPanel   panel=null;
 JLabel[]   label   =   new   JLabel[BigProblem.length];; public   tables()
 {
 aWindow=new   JFrame("Testing.....");
 panel=new   JPanel();
 JButton   button1=new   JButton("Dynamic   Create"); aWindow.setBounds(0,0,   300,300);
 aWindow.getContentPane().add(panel);
 panel.add(button1); button1.addActionListener(this); aWindow.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
 aWindow.setVisible(true);
 }
 public   void   actionPerformed(ActionEvent   e)
 {
 JOptionPane.showMessageDialog(aWindow,"Sucess","Frame   Info",
 JOptionPane.PLAIN_MESSAGE);
 int   big=BigProblem.length;
 int   small=problem.length; for(int   i=0;i<big;i++)
 {
 label[i]=new   JLabel(BigProblem[i]);
 panel.add(label[i]);
 panel.validate();
 System.out.println(label[i]);
 }
 } public   static   void   main(String[]   args)
 {
 new   tables();
 }
 }