62,614
社区成员
发帖
与我相关
我的任务
分享
public class LiveTest extends JFrame implements ActionListener{
JButton jb = new JButton("TEST");
public LiveTest(){
this.setTitle("测试程序");
this.setSize(346, 458);
this.setLayout(new FlowLayout(FlowLayout.LEFT));
this.add(jb);
jb.addActionListener(this);
this.setLocation(200,120);
this.setVisible(true);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
public void paintComponent(Graphics g) {
super.paintComponents(g);
g.setColor(new Color(0, 255, 255));
g.fillRect(230, 230, 230, 230);
}
public static void main(String[] args) {
// TODO Auto-generated method stub
new LiveTest();
}
@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
if (e.getSource() == jb) {
repaint();
}
}
}