事件处理


package
事件处理; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.*; public class Xiu implements ActionListener { JFrame f; JPanel p; JButton b; public Xiu() { f=new JFrame(); p=new JPanel(); b=new JButton("单击"); b.addActionListener(this); f.setSize(400,450); f.add(p); p.add(b); f.setVisible(true); } public static void main(String[] args) { new Xiu(); } @Override public void actionPerformed(ActionEvent arg0) { p.setBackground(Color.BLUE); } }

 

posted on 2019-06-16 16:11  枫少少  阅读(70)  评论(0编辑  收藏  举报

导航