里用内部类,可以实现多个按钮事件。
内部的两个类
/*class LabelListener implements ActionListener{
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
label.setText("我已经改变咯!");
}
}
class ColorListener implements ActionListener{
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
frame.repaint();
}
}*/
实现指定的监听
/*labelbutton.addActionListener(new LabelListener());//实现两个监听
colorbutton.addActionListener(new ColorListener());*/
颜色
Graphics g;
g.setColor(Color.white);
g.fillRect(0,0,500,250);// 填充范围