⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 usergui.java~1~

📁 一个可以实现联网售票的火车售票管理系统
💻 JAVA~1~
字号:
package train.gui;

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.event.*;
import javax.swing.table.*;
import train.parameter.User;
import train.parameter.CommonConstant;

/**
 * <p>Title: </p>
 *
 * <p>Description: </p>
 *
 * <p>Copyright: Copyright (c) 2006</p>
 *
 * <p>Company: 沈阳化工学院计算机</p>
 *
 * @author 彭胜勇 胡林
 * @version 1.0
 */
//需要写方法判断两次输入的密码是不是一致
public class UserGUI extends JFrame {
    public UserGUI() {
        try {
            jbInit();
            this.setSize(600, 375);
            this.setLocation(262, 197);
            this.setTitle("用户信息管理");
            this.setVisible(true);
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }

    private void jbInit() throws Exception {
        datajToolBar.setFont(fontS);
        userIDjLabel.setFont(fontS);
        userIDjTextField.setFont(fontS);
        userNamejLabel.setFont(fontS);
        userNamejTextField.setFont(fontS);
        userPasswordjLabel.setFont(fontS);
        userjPasswordField.setFont(fontS);
        userjScrollPane.setFont(font);
        userjTable.setFont(font);
        operatejToolBar.setFont(font);
        insertjBotton.setFont(font);
        updatejBotton.setFont(font);
        deletetejBotton.setFont(font);
        userStatejLabel.setFont(font);
        canceljBotton.setFont(font);
        userPasswordSurejLabel.setFont(font);
        userPasswordSurejPasswordField.setFont(font);
        ///////////////////////////////////////////
        userIDjLabel.setText("ID:");
        userNamejLabel.setText("姓名:");
        userPasswordjLabel.setText("密码:");
        insertjBotton.setText("插入");
        updatejBotton.setText("修改");
        deletetejBotton.setText("删除");
        userStatejLabel.setText("就绪状态!");
        canceljBotton.setText("取消");
        userPasswordSurejLabel.setText("密码确认");
        //////////////////////////////////////////
        datajToolBar.add(userIDjLabel);
        datajToolBar.add(userIDjTextField);
        datajToolBar.add(userNamejLabel);
        datajToolBar.add(userNamejTextField);
        datajToolBar.add(userPasswordjLabel);
        datajToolBar.add(userjPasswordField);
        /////////////////////////////////////////
        operatejToolBar.add(insertjBotton);
        operatejToolBar.add(updatejBotton);
        operatejToolBar.add(deletetejBotton);
        operatejToolBar.add(canceljBotton);
        operatejToolBar.add(userPasswordSurejLabel);
        operatejToolBar.add(userPasswordSurejPasswordField);
        operatejToolBar.add(userStatejLabel);
        ///////////////////////////////////////////
        this.getContentPane().add(operatejToolBar, java.awt.BorderLayout.SOUTH);
        this.getContentPane().add(datajToolBar, java.awt.BorderLayout.NORTH);
        this.getContentPane().add(userjScrollPane, java.awt.BorderLayout.CENTER);
        ///////////////////////////////////////////
        userjScrollPane.getViewport().add(userjTable, null);
        ///////////////////////////////////////////
        this.canceljBotton.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                userIDjTextField.setText("");
                userNamejTextField.setText("");
                userjPasswordField.setText("");
                userPasswordSurejPasswordField.setText("");
            }
        });

    }

    Font font = new java.awt.Font("Dialog", Font.BOLD, 15);
    Font fontS = new java.awt.Font("Dialog", Font.BOLD, 20);
    JToolBar datajToolBar = new JToolBar();
    JLabel userIDjLabel = new JLabel();
    JTextField userIDjTextField = new JTextField();
    JLabel userNamejLabel = new JLabel();
    JTextField userNamejTextField = new JTextField();
    JLabel userPasswordjLabel = new JLabel();
    JPasswordField userjPasswordField = new JPasswordField();
    JScrollPane userjScrollPane = new JScrollPane();
    JTable userjTable = new JTable();
    JToolBar operatejToolBar = new JToolBar();
    JButton insertjBotton = new JButton();
    JButton updatejBotton = new JButton();
    JButton deletetejBotton = new JButton();
    JLabel userStatejLabel = new JLabel();
    JButton canceljBotton = new JButton();
    JLabel userPasswordSurejLabel = new JLabel();
    JPasswordField userPasswordSurejPasswordField = new JPasswordField();

    public static void main(String[] args) {
        UserGUI usergui = new UserGUI();
    }


    public void setUserID(String userID) {
        this.userIDjTextField.setText(userID);
    }

    public String getUserID() {
        return this.userIDjTextField.getText();
    }

    public void setUserName(String userName) {
        this.userNamejTextField.setText(userName);
    }

    public String getUserName() {
        return this.userNamejTextField.getText();
    }

    public void setUserPassword(String userPassword) {
        this.userjPasswordField.setText(userPassword);
    }

    public String getUserPassword() {
        char pass[] = this.userjPasswordField.getPassword();
        String firstPassword = null;
        return firstPassword.copyValueOf(pass);
    }

    public void setUserPasswordSure(String userPassword) {
        this.userPasswordSurejPasswordField.setText(userPassword);
    }

    public String getUserPasswordSure() {
        char password[] = this.userPasswordSurejPasswordField.getPassword();
        String secondPassword = null;
        return secondPassword.copyValueOf(password);
    }

    public void setContent(java.util.List list) {
        userjTable.updateUI();
    }

    public int getUserjTableSelectedObject() {
        return userjTable.getSelectedRow();
    }

    public void setUserjTableSelectedObject(int i) {
        userjTable.changeSelection(i, -1, true, false);
    }

    public void showUserStatus(Object obj) {
        this.userStatejLabel.setText(obj == null ? "null" : obj.toString());
    }

    public boolean firstEqualsSecond() {
        return getUserPasswordSure().equals(getUserPassword());
    }

    public void warnSurePassword() {
        JOptionPane.showMessageDialog(null, "两次输入密码不一致!", "错误提示",
                                      JOptionPane.WARNING_MESSAGE);
    }

    public void userGuiRegister(ActionListener al[],
                                ListSelectionListener lslList[],
                                TableModel atm) {
        this.insertjBotton.addActionListener(al[0]);
        this.deletetejBotton.addActionListener(al[1]);
        this.updatejBotton.addActionListener(al[2]);
        this.userjTable.getSelectionModel().addListSelectionListener(
                lslList[0]);
        this.userjTable.setModel(atm);
        this.userjTable.getSelectionModel().setSelectionMode(
                ListSelectionModel.
                SINGLE_SELECTION);
    }


}


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -