欢迎来到天天文库
浏览记录
ID:37852012
大小:56.00 KB
页数:5页
时间:2019-06-01
《Java实验报告计12—2》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、内蒙古科技大学信息工程学院计算机系《Java核心技术(上)》实验报告姓名刘如意学号1267111215实验成绩班级计算机2班实验日期第8周周三4月15日下午实验名称上机练习实验内容packagelyb;importjava.awt.GridLayout;importjava.awt.event.ActionEvent;importjava.awt.event.ActionListener;importjava.awt.event.WindowAdapter;importjava.awt.event.WindowEvent;importjava.io.BufferedRead
2、er;importjava.io.FileReader;importjava.io.FileWriter;importjava.io.IOException;importjava.io.PrintWriter;importjava.util.Calendar;importjavax.swing.JButton;importjavax.swing.JFrame;importjavax.swing.JPanel;importjavax.swing.JScrollPane;importjavax.swing.JTextArea;publicclassChuangKouimplem
3、entsActionListener{Stringstring="";JTextAreajTextArea;JFramejFrame;JButtonbutton1;JButtonbutton2;JButtonbutton3;JPanelpanel;JPanelpanel2;privateStringfile="F:/留言版/1.txt";publicstaticvoidmain(Stringargs[]){newChuangKou().gui();}publicvoidgui(){jFrame=newJFrame("简易留言板");jTextArea=newJTextAre
4、a(20,20);panel=newJPanel();panel2=newJPanel();panel.setLayout(newGridLayout(1,2));5panel2.setLayout(newGridLayout(1,1));button1=newJButton("查看/刷新留言");button2=newJButton("我要留言");button3=newJButton("清空历史留言");panel.add(button1,"West");panel.add(button2,"Center");panel.add(button3,"East");jFra
5、me.add(panel,"North");jFrame.add(panel2,"East");jFrame.addWindowListener(newWindowAdapter(){publicvoidwindowClosing(WindowEvente){System.exit(0);}});button1.addActionListener(this);button2.addActionListener(this);button3.addActionListener(this);jTextArea.setLineWrap(true);JScrollPanejScrol
6、lPane=newJScrollPane(jTextArea);jFrame.getContentPane().add(jScrollPane);jScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);panel2.add(jScrollPane,"East");jFrame.add(jTextArea,"Center");jFrame.setSize(400,500);jFrame.setLocation(300,100);jFrame.setVisible(true);}
7、publicstaticStringnowTime(){Calendartime=Calendar.getInstance();returntime.getTime().toString();}@OverridepublicvoidactionPerformed(ActionEvente){Strings=e.getActionCommand();if(s.equals("查看/刷新留言")){string="";jTextArea.setText("");jTextArea.setText(dufile());}
此文档下载收益归作者所有