资源预览内容
第1页 / 共9页
第2页 / 共9页
第3页 / 共9页
第4页 / 共9页
第5页 / 共9页
第6页 / 共9页
第7页 / 共9页
第8页 / 共9页
第9页 / 共9页
亲,该文档总共9页全部预览完了,如果喜欢就下载吧!
资源描述
Timer.java文件package common;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import java.text.SimpleDateFormat;import java.util.Date;import javax.swing.Timer;import javax.swing.JTextField;public class TimeDate now ; Timer timer; JTextField lbl; public Time( JTextField l) lbl=l; timer = new Timer(1000, new ActionListener() public void actionPerformed(ActionEvent e) now = new Date(now.getTime() - 1000); SimpleDateFormat formatter = new SimpleDateFormat(HH:mm:ss); lbl.setText(formatter.format(now); ); SuppressWarnings(deprecation)public void time_start() / lbl.setText(00:00:10); now = new Date(); now.setHours(0); now.setMinutes(0); now.setSeconds(10); timer.start(); public void time_stop() timer.stop(); lbl.setText(00:00:10); public void time_restart(); timer.stop();this.time_start(); ARQ.java文件import java.awt.*;import java.awt.event.*;import javax.swing.BoxLayout;import javax.swing.JFrame;import javax.swing.JLabel;import javax.swing.JButton;import javax.swing.JScrollPane;import javax.swing.JTextField;import javax.swing.JPanel;import javax.swing.JRadioButton;import javax.swing.ButtonGroup;import javax.swing.JTable;import javax.swing.event.DocumentEvent;import javax.swing.event.DocumentListener;import javax.swing.table.*;import javax.swing.text.Document;import java.io.FileWriter;import java.io.IOException;import common.Time;public class ARQ extends JFrame private static final long serialVersionUID = -5437589209629747957L; private int NUM; private Time T; private JTextField status; private JButton b; private JRadioButton r; DefaultTableModel m_data; JTable m_view; FileWriter f1; FileWriter f2; FileWriter f3;public ARQ() throws IOException super(ARQ); NUM=0; Container c=getContentPane(); c.setLayout(new FlowLayout(); JPanel P=new JPanel2; P0=new JPanel(); P0.setLayout(new BoxLayout(P0,BoxLayout.X_AXIS); c.add(P0); P1=new JPanel(); c.add(P1); JPanel Q=new JPanel2; Q0=new JPanel(); Q0.setLayout(new BoxLayout(Q0,BoxLayout.Y_AXIS); P0.add(Q0); Q1=new JPanel(); Q1.setLayout(new BoxLayout(Q1,BoxLayout.Y_AXIS); P0.add(Q1); JPanel R=new JPanel4; R0=new JPanel(); R0.setLayout(new FlowLayout(FlowLayout.LEFT); Q0.add(R0); R1=new JPanel(); R1.setLayout(new FlowLayout(FlowLayout.LEFT); Q0.add(R1); R2=new JPanel(); R2.setLayout(new FlowLayout(FlowLayout.LEFT); Q0.add(R2); R3=new JPanel(); R3.setLayout(new FlowLayout(FlowLayout.CENTER); Q0.add(R3); /文件 f1=new FileWriter(f1.txt,true); f2=new FileWriter(f2.txt,true); f3=new FileWriter(f3.txt,true); /数据发送状态 JTextField s=new JTextField(新数据,7), new JTextField(重发,7) , new JTextField(倒计时,4), new JTextField(00:00:10,10), new JTextField(数据,4), new JTextField(,15) ; /数据发送住状态 status=s; status0.setEditable(false); status1.setEditable(false); status2.setEditable(false); status4.setEditable(false); status1.setEnabled(false); JLabel l=new JLabel(状态: ); R0.add(l); R0.add(status0); R1.add(status2); R1.add(status3); R2.add(status4); R2.add(status5); b=new JButton(发送); b.setEnabled(false); R3.add(b); JLabel l1=new JLabel(选择操作); Q1.add(l1); / 选择操作 JRadioButton r1=new JRadioButton(ACK), new JRadioButton(NAK), new JRadioButton(不处理), new JRadioButton(初始) ; r=r1; ButtonGroup rg=new ButtonGroup(); for(int i=0;ir.length-1;i+) Q1.add(ri); rg.add(ri); rg.add(r3); / /数据收发住状态列表 m_data=new DefaultTableModel(); m_view=new JTable(m_data); m_view.setPreferredScrollableViewportSize(new Dimension(300,230); /表格大小 m_view.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); JScrollPane sPane=new JScrollPane(m_view); P1.add(sPane); T=new Time(status3); /发送操作 b.addActionListener(new ActionListener() public void actionPerformed(ActionEvent e) T.time_start(); newtore();status0.setText(新数据);r3.setSelected(true);
网站客服QQ:2055934822
金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号