JAVA鼠标键监听.docVIP

  • 4
  • 0
  • 约1.26万字
  • 约 12页
  • 2017-03-09 发布于贵州
  • 举报
JAVA鼠标键监听

《Java编程》实验报告 班级 学号 任课教师 姓名 成绩 课程名称 《Java编程》 实验时间 实验题目 实验11 实验内容 package lrs; import java.awt.*; import java.awt.event.*; import javax.swing.*; public class Experiment11_1 extends JFrame implements ActionListener JPanel jp null; JButton jb1 null; JButton jb2 null; JButton jb3 null; JButton jb4 null; JButton jb5 null; JButton jb6 null; public static void main String[] args // TODO Auto-generated method stub new Experiment11_1 ; public Experiment11_1 jp new JPanel ; jb1 new JButton Button 1 ; jb2 new JButton Button 2 ; jb3 new JButton Button 3 ; jb4 new JButton Button 4 ; jb5 new JButton Button 5 ; jb6 new JButton Button 6 ; jb1.addActionListener this ; jb2.addActionListener this ; jb3.addActionListener this ; jb4.addActionListener this ; jb5.addActionListener this ; jb6.addActionListener this ; jb1.setActionCommand 1 ; jb2.setActionCommand 2 ; jb3.setActionCommand 3 ; jb4.setActionCommand 4 ; jb5.setActionCommand 5 ; jb6.setActionCommand 6 ; jp.setLayout new FlowLayout ; jp.add jb1 ; jp.add jb2 ; jp.add jb3 ; jp.add jb4 ; jp.add jb5 ; jp.add jb6 ; this.add jp ; this.setLayout new FlowLayout ; this.setTitle 六个按钮 ; this.setSize 550, 80 ; this.setLocationRelativeTo null ; this.setVisible true ; this.setDefaultCloseOperation EXIT_ON_CLOSE ; @Override public void actionPerformed ActionEvent e // TODO Auto-generated method stub int i Integer.parseInt e.getActionCommand ; System.out.println Button +i+ was clickek ; package lrs; import java.awt.*; import java.awt.event.*; import javax.swing.*; public class Experiment11_2 extends JFrame implements ActionListener MyPanel mp null; JPanel jp null; JButton jb1 null; JButton jb2 null; JButton jb3 null; JButton jb4 null; public static void main String[] args // TODO Auto-generated method stub new Experiment11_2 ; public Experiment11_2 mp new MyPanel ; jp new JPanel ; jb1 new JButton Left ; jb2 new JButton Right ; j

文档评论(0)

1亿VIP精品文档

相关文档