第七次实验报告--Swing及事件.docVIP

  • 78
  • 0
  • 约4.73千字
  • 约 7页
  • 2020-11-04 发布于广东
  • 举报
辽宁工程技术大学上机实验报告 成绩 实验名称 实验七 swing 及事件 院系 理学院 专业 理科实验班 班级 理科 13-1 姓名 学号 27 日期 2015/5/6 简述本次实验目的: ( 1)熟悉 AWT标签、文本框、按钮等组件的使用方法。实验 ( 2)熟悉事件处理方法 目的 你为本次实验做了哪些准备:课下复习老师上课讲的关于面板的设置等有关知识, 实践运用了文本框的组件、按钮的设置,熟悉了时间的处理方法。 实验 准备 实验 本次共有 3 个练习,完成 3 个。 进度 本次实验的收获、体会、经验、问题和教训:这次实验我更加体会到了 JAVA 的用途,一个简单的面板是通过程序实现的,应用广泛,我应该更好的学习。 实验总结 教师评语 实验要求 : 组件在窗口中的位置尽量按要求摆放。 响应窗口的环比事件。 实验四不需要写在报告上。 实验内容 : 设计一个简易计算器,在“操作数”标签右侧的两个文本框输入操作数,当单击“ +, - , * , / ”按钮时,对两个操作数进行运算并将结果填到“结果”标签右侧的文本框中。程序: import .*; import .*; import MyApp extends JFrame{ JTextField b1=new JTextField( 0 ,12); JTextField b2 =new JTextField( 0 ,12); JTextField b3 =new JTextField( 0 ,12); JTextField b4 =new JTextField( 0 ,12); MyApp(){ super ( 简易计算器 ); Container c=getContentPane(); ( new FlowLayout()); JPanel a1 = new JPanel( new FlowLayout()); JPanel a2 = new JPanel( new FlowLayout()); JPanel a3 = new JPanel( new FlowLayout()); JPanel a4 = new JPanel( new FlowLayout()); JPanel a5 = new JPanel( new FlowLayout()); JLabel jb1 = new JLabel( 数 字 一 : ); JLabel jb2 = new JLabel( 数 字 二 : ); JLabel jb3 = new JLabel( 操 作 : ); JLabel jb4 = new JLabel( 结 果 : ); JButton c1= new JButton( + ); JButton c2= new JButton( - ); JButton c3= new JButton( * ); JButton c4= new JButton( / ); JButton c5= new JButton( 重置 ); (jb1); ( b1); (jb2); ( b2); (jb3); (c1); (c2); (c3); (c4); (jb4); ( b4); (c5); (a1); (a2); (a3); (a4); (a5); ( new ActionListener(){ public void actionPerformed(ActionEvent e){ E1(e); } }); ( new ActionListener(){ public void actionPerformed(ActionEvent e){ E2(e); } }); ( new ActionListener(){ public void actionPerformed(ActionEvent e){ E3(e); } }); ( new ActionListener(){ public void actionPerformed(ActionEvent e){ E4(e); } }); ( new ActionListener(){ public void actionPerformed(ActionEvent e){ E5(e); } }); setSize(270,250); setVisible( true ); setDefaultCloseOperation; } protected void E1(ActionEvent e){ double z1=()); double z2=()); DecimalFormat f1= new DecimalFormat( #.000 ); String s1=(z1+z2); (s1); } protecte

文档评论(0)

1亿VIP精品文档

相关文档