驾考系统设计-java

相关项目已经上传github

自取 https://github.com/grey-wood-wolf/Driving-school-test-system

可以使用eclipse等编译软件,按照README.txt中进行运行

以下是实际演示效果

 

 

 

 

 部分相关代码:

package pro;  
  
import java.util.*;  
import java.awt.EventQueue;  
import javax.swing.JFrame;  
import javax.swing.JPanel;  
import javax.swing.border.EmptyBorder;  
import javax.swing.JButton;  
import javax.swing.JLabel;  
import javax.swing.SwingConstants;  
import javax.swing.JPasswordField;  
import javax.swing.JFormattedTextField;  
import java.awt.Font;  
import java.awt.event.ActionListener;  
import java.awt.event.ActionEvent;  
import java.awt.Color;  
import java.awt.SystemColor;  
import javax.swing.JTextArea;  
  
public class Test02 extends JFrame {  
      
      
    /** 
     *  
     */  
    private static final long serialVersionUID = 1L;  
    int score=0;//得分  
    //账号和密码  
    private JPanel contentPane;  
    private JPasswordField passwordField;  
  
    /** 
     * Launch the application. 
     */  
    public static void main(String[] args) {  
        EventQueue.invokeLater(new Runnable() {  
            public void run() {  
                try {  
                    Test02 frame = new Test02();  
                    frame.setVisible(true);  
                } catch (Exception e) {  
                    e.printStackTrace();  
                }  
            }  
        });  
    }  
  
    /** 
     * Create the frame. 
     */  
    public Test02() {         
          
        //JFrame设置  
        setResizable(false);  
        setTitle("\u9A7E\u8003\u6A21\u62DF\u8003\u8BD5\u7CFB\u7EDF");  
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);  
        setBounds(100, 100, 450, 300);  
        setLocationRelativeTo(Test02.this.getOwner());  
        contentPane = new JPanel();  
        contentPane.setBackground(Color.DARK_GRAY);  
        contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));  
        setContentPane(contentPane);  
        contentPane.setLayout(null);  
          
        //试用  
        JButton btnNewButton = new JButton("\u8BD5\u7528");//试用  
        btnNewButton.setFont(new Font("华光书宋一_CNKI", Font.BOLD, 10));  
        btnNewButton.setBackground(SystemColor.controlHighlight);  
        btnNewButton.setBounds(356, 204, 59, 47);  
        contentPane.add(btnNewButton);  
          
        JLabel lblNewLabel = new JLabel("\u8D26\u53F7\uFF1A");  
        lblNewLabel.setForeground(Color.CYAN);  
        lblNewLabel.setFont(new Font("华光胖头鱼_CNKI", Font.PLAIN, 15));  
        lblNewLabel.setHorizontalAlignment(SwingConstants.RIGHT);  
        lblNewLabel.setBounds(106, 97, 54, 15);  
        contentPane.add(lblNewLabel);  
          
        JLabel lblNewLabel_1 = new JLabel("\u5BC6\u7801\uFF1A");  
        lblNewLabel_1.setForeground(Color.CYAN);  
        lblNewLabel_1.setFont(new Font("华光胖头鱼_CNKI", Font.PLAIN, 15));  
        lblNewLabel_1.setHorizontalAlignment(SwingConstants.RIGHT);  
        lblNewLabel_1.setBounds(106, 122, 54, 15);  
        contentPane.add(lblNewLabel_1);  
          
        //密码  
        passwordField = new JPasswordField();  
        passwordField.setBackground(SystemColor.controlHighlight);  
        passwordField.setBounds(181, 119, 119, 21);  
        contentPane.add(passwordField);  
          
        JFormattedTextField formattedTextField = new JFormattedTextField();  
        formattedTextField.setBackground(SystemColor.controlHighlight);  
        formattedTextField.setFont(new Font("华光胖头鱼_CNKI", Font.BOLD, 13));  
        formattedTextField.setBounds(181, 94, 119, 21);  
        contentPane.add(formattedTextField);  
          
        JLabel lblNewLabel_2 = new JLabel("\u6B22\u8FCE\u8FDB\u5165\u9A7E\u8003\u6A21\u62DF\u8003\u8BD5\u7CFB\u7EDF");  
        lblNewLabel_2.setForeground(new Color(255, 165, 0));  
        lblNewLabel_2.setFont(new Font("宋体", Font.BOLD, 21));  
        lblNewLabel_2.setHorizontalAlignment(SwingConstants.CENTER);  
        lblNewLabel_2.setBounds(50, 10, 325, 54);  
        contentPane.add(lblNewLabel_2);  
          
        //登录  
        JButton btnNewButton_1 = new JButton("\u767B\u5F55");  
        btnNewButton_1.setFont(new Font("宋体", Font.BOLD, 20));  
        btnNewButton_1.setBackground(SystemColor.controlHighlight);  
        btnNewButton_1.setBounds(181, 170, 108, 47);  
        contentPane.add(btnNewButton_1);  
          
        //游客监听  
        btnNewButton.addActionListener(new ActionListener() {  
            public void actionPerformed(ActionEvent e) {  
                Test02.this.dispose();  
                //开启下一个JFrame  
                try {  
                    ChooseJFrame frame = new ChooseJFrame(Test02.this.score);  
                    frame.setVisible(true);  
                } catch (Exception a) {  
                    a.printStackTrace();  
                }  
            }  
        });  
          
        //用户登录  
        btnNewButton_1.addActionListener(new ActionListener() {  
            public void actionPerformed(ActionEvent e) {  
                if("2020010904022".equals(formattedTextField.getText())  
                &&"lzl18349118192".equals(new String(passwordField.getPassword()))) {  
                    Test02.this.dispose();  
                    //开启下一个JFrame  
                    try {  
                        ChooseJFrame frame = new ChooseJFrame(Test02.this.score);  
                        frame.setVisible(true);  
                    } catch (Exception a) {  
                        a.printStackTrace();  
                    }  
                }  
            }  
        });  
    }  
}  
  
  
//计时器类  
class Schedule extends TimerTask{  
    static int time=60;//60mins  
      
    ChooseJFrame framec;  
    JTextArea textArea;  
    Test01 test01;  
    WriteJFrame writejframe;  
      
    public Schedule(JTextArea textArea,ChooseJFrame framec,Test01 test01,WriteJFrame writejframe) {  
        this.textArea=textArea;  
        this.framec=framec;  
        this.test01=test01;  
        this.writejframe=writejframe;  
    }  
      
    @Override  
    public void run() {  
        time-=1;//分钟数减一  
        this.textArea.setText("剩余"+time+"分钟");  
        //时间到了  
        if(time==0) {  
            System.out.println(0);  
              
            //三种题型不同的计时器  
            if(framec!=null) {  
                for(int i=0 ;i<framec.rightans.length;i++) {  
                    if(framec.rightans[i].equals(framec.yourans[i])) {  
                        framec.score+=1;  
                    }  
                }  
                framec.timer.cancel();  
                framec.dispose();  
                EndJFrame frame = new EndJFrame(framec.score);  
                frame.setVisible(true);  
            }  
            if(test01!=null) {  
                for(int i=0 ;i<test01.rightans.length;i++) {  
                    if(test01.rightans[i].equals(test01.yourans[i])) {  
                        test01.score+=1;  
                    }  
                }  
                test01.timer.cancel();  
                test01.dispose();  
                EndJFrame frame = new EndJFrame(test01.score);  
                frame.setVisible(true);  
            }  
            if(writejframe!=null) {  
                for(int i=0 ;i<writejframe.rightans.length;i++) {  
                    if(writejframe.rightans[i].equals(writejframe.yourans[i])) {  
                        writejframe.score+=1;     
                    }  
                }  
                writejframe.timer.cancel();  
                writejframe.dispose();  
                EndJFrame frame = new EndJFrame(writejframe.score);  
                frame.setVisible(true);  
            }  
        }  
    }  
}

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值