团队博客地址html
按钮设置java
1.框架构建架构
public TimeFrame() { add(new TimePanel()); this.setTitle("定时器"); this.setSize(1200, 800); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); this.setLocationRelativeTo(null); this.setResizable(false); this.setVisible(true); }
2.建立类框架
class TimePanel extends JPanel implements ActionListener, KeyListener, Runnable { /** * */ private static final long serialVersionUID = 1L; private int setTime; private int showTime; // 定义是否计时变量 private boolean flag = false; private JPanel jpShowTime, jpSetting, jpTimeInfo; private JLabel labTime, labSetTime, labPassTime, labRemainTime; private JButton btnBegin; private JButton btnPause; private JButton btnContinue; private JButton btnHidden; private JButton btnShow; private JButton btnExit; // 倒计时设置 private JPanel jpTimeSetting; private JTextField tfdHours; private JTextField tfdMinutes; private JTextField tfdSeconds; public TimePanel() { this.setSize(1200, 800); this.setLayout(null); createSetting(); createShowTime(); jpSetting.addKeyListener(this); jpSetting.setFocusable(true); }
3.建立倒计时面板、设置时间面板、倒计时属性面板、时间信息面板this
void createShowTime() { jpShowTime = new JPanel(); jpShowTime.setSize(1200, 400); jpShowTime.setBackground(Color.BLACK); labTime = new JLabel("00 : 00 : 00", JLabel.CENTER); labTime.setFont(new Font("微软雅黑", 1, 200)); labTime.setForeground(Color.RED); jpShowTime.add(labTime); add(jpShowTime).setBounds(0, 400, 1200, 400); } void createSetting() { jpSetting = new JPanel(); jpSetting.setSize(1200, 400); jpSetting.setLayout(null); createTimeSetting(); createTimeInfo(); // 开始按钮 btnBegin = new JButton("开始[F8]"); jpSetting.add(btnBegin).setBounds(700, 50, 80, 50); // 暂停按钮 btnPause = new JButton("暂停[F9]"); jpSetting.add(btnPause).setBounds(800, 50, 80, 50); // 继续按钮 btnContinue = new JButton("继续[F10]"); jpSetting.add(btnContinue).setBounds(900, 50, 80, 50); // 隐藏按钮 btnHidden = new JButton("隐藏[F11]"); jpSetting.add(btnHidden).setBounds(700, 120, 80, 50); // 显示按钮 btnShow = new JButton("显示[F12]"); jpSetting.add(btnShow).setBounds(800, 120, 80, 50); // 帮助按钮 btnExit = new JButton("退出"); jpSetting.add(btnExit).setBounds(900, 120, 80, 50); btnBegin.addActionListener(this); btnPause.addActionListener(this); btnContinue.addActionListener(this); btnHidden.addActionListener(this); btnShow.addActionListener(this); btnExit.addActionListener(this); add(jpSetting).setBounds(0, 0, 1200, 400); } void createTimeSetting() { jpTimeSetting = new JPanel(); jpTimeSetting.setSize(300, 200); jpTimeSetting.setLayout(new FlowLayout()); jpTimeSetting.add(tfdHours = new JTextField(3)); jpTimeSetting.add(new JLabel("时")); jpTimeSetting.add(tfdMinutes = new JTextField(3)); jpTimeSetting.add(new JLabel("分")); jpTimeSetting.add(tfdSeconds = new JTextField(3)); jpTimeSetting.add(new JLabel("秒")); tfdHours.addKeyListener(this); tfdMinutes.addKeyListener(this); tfdSeconds.addKeyListener(this); jpSetting.add(jpTimeSetting).setBounds(100, 100, 300, 200); } void createTimeInfo() { jpTimeInfo = new JPanel(); jpTimeInfo.setLayout(null); jpTimeInfo.setBackground(new Color(154, 217, 250)); jpTimeInfo.setSize(1200, 100); // 总秒数 labSetTime = new JLabel("计时总秒数 : ", JLabel.CENTER); labSetTime.setFont(new Font("微软雅黑", 0, 20)); jpTimeInfo.add(labSetTime).setBounds(0, 10, 400, 80); // 已过秒数 labPassTime = new JLabel("已过秒数 : ", JLabel.CENTER); labPassTime.setFont(new Font("微软雅黑", 0, 20)); jpTimeInfo.add(labPassTime).setBounds(400, 10, 400, 80); // 剩余秒数 labRemainTime = new JLabel("剩余秒数 : ", JLabel.CENTER); labRemainTime.setFont(new Font("微软雅黑", 0, 20)); jpTimeInfo.add(labRemainTime).setBounds(800, 10, 400, 80); jpSetting.add(jpTimeInfo).setBounds(0, 300, 1200, 100); }
虽然时间紧迫,可是作了组长仍是要负责好课设,因而和组员一直讨论要怎么搞才好,沟通交流是作课设最主要的,分配好各自的工做而后讨论交流才让咱们的课设最终完成。最后的最后,不懂的~要百度~