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

📄 statepanel.java

📁 图书馆座位管理系统
💻 JAVA
字号:
package librarysearchingsystem;

import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.*;

import fileUtility.ReadingRoom;

public class StatePanel extends JPanel implements ActionListener {
    Frame f;
//    static Student stu;
    public StatePanel() {
        try {
            jbInit();
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }

    public StatePanel(Frame f) {
        this.f = f;

        try {
            jbInit();

        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }


    private void jbInit() throws Exception {
        this.setLayout(null);
        this.setPreferredSize(new Dimension(240, 78));
        nameTextField.setText("");
        nameTextField.setBounds(new Rectangle(60, 2, 181, 22));
        nameTextField.setFont(new java.awt.Font("Dialog", Font.PLAIN, 14));
        nameTextField.setPreferredSize(new Dimension(130, 25));
        nameTextField.setDisabledTextColor(Color.black);
        nameTextField.setEditable(false);
        nameLabel.setFont(new java.awt.Font("Dialog", Font.PLAIN, 14));
        nameLabel.setHorizontalAlignment(SwingConstants.CENTER);
        nameLabel.setText("姓名:");
        nameLabel.setBounds(new Rectangle(0, 0, 54, 27));
        stateLabel.setFont(new java.awt.Font("Dialog", Font.PLAIN, 14));
        stateLabel.setHorizontalAlignment(SwingConstants.CENTER);
        stateLabel.setHorizontalTextPosition(SwingConstants.CENTER);
        stateLabel.setText("状态:");
        stateLabel.setBounds(new Rectangle(0, 24, 54, 27));
        leaveLibButton.setBounds(new Rectangle(6, 46, 64, 24));
        leaveLibButton.setFont(new java.awt.Font("隶书", Font.PLAIN, 14));
        leaveLibButton.setText("离开");
        changePasswordButton.setBounds(new Rectangle(150, 46, 92, 24));
        changePasswordButton.setFont(new java.awt.Font("隶书", Font.PLAIN, 14));
        changePasswordButton.setActionCommand("寻找自己");
        changePasswordButton.setText("修改密码");
        stateButton.setFont(new java.awt.Font("Dialog", Font.PLAIN, 12));
        stateButton.setBounds(new Rectangle(59, 27, 181, 21));
        signOutButton.setBounds(new Rectangle(77, 46, 71, 24));
        signOutButton.setFont(new java.awt.Font("隶书", Font.PLAIN, 14));
        signOutButton.setText("注销");
        this.add(stateLabel, null);
        this.add(leaveLibButton, null);
        this.add(changePasswordButton, null);
        this.add(nameLabel, null);
        this.add(nameTextField, null);
        this.add(stateButton, null);
        this.add(signOutButton);

        leaveLibButton.addActionListener(new ButtonAction());
        changePasswordButton.addActionListener(new ButtonAction());
        signOutButton.addActionListener(new ButtonAction());
        stateButton.addActionListener(new ButtonAction());
        this.setVisible(true);
        this.setOpaque(true);
    }

    JTextField nameTextField = new JTextField();
    JLabel nameLabel = new JLabel();
    JLabel stateLabel = new JLabel();
    JButton leaveLibButton = new JButton();
    JButton changePasswordButton = new JButton();
    JButton stateButton = new JButton();
    JButton signOutButton = new JButton();
    public void actionPerformed(ActionEvent e) {

    }

    public void refresh(ReadingRoom r) {
        nameTextField.setText(f.stu.name);
        if (r != null) {
            stateButton.setText("您在" + r.name);
            stateButton.setEnabled(true);
        } else if (f.stu.readingRoom != null) {
            stateButton.setText("您在" + f.stu.readingRoom.name);
            stateButton.setEnabled(true);
        } else {
            stateButton.setText("您尚未进入阅览室");
            stateButton.setEnabled(false);
        }
    }

    void signOut() {
        f.stu = null;
        f.changeToNavigationPanel();
        f.changeStatePanelToLogPanel();
        f.changeFriendsPanelToNoramal();

    }


    class ButtonAction implements ActionListener {
        public void actionPerformed(ActionEvent e) {
            if (e.getSource() == leaveLibButton) {
                if (f.stu.readingRoom != null) {
                    f.stu.readingRoom.proportionPanel.refresh( -1);
                    f.stu.readingRoom.map[f.stu.seatY][f.stu.seatX] =
                            ReadingRoom.seatNum;
                    f.stu.readingRoom = null;

                }

                signOut();
                new TipsDialog("您已经离开阅览室");
            }

            if (e.getSource() == stateButton) {
                if (f.stu.readingRoom != null) {
                    if (f.readingRoomPanel == null ||
                        f.stu.readingRoom != f.readingRoomPanel.r) {
                        f.changeToreadingRoom(f.stu.readingRoom);
                    }

                } else {
                    new TipsDialog("您尚未选择座位");
                }
            }

            if (e.getSource() == signOutButton) {
                signOut();
            }
            if (e.getSource() == changePasswordButton) {
                new ChangePasswordDialog(f);
            }
        }


    }

}

⌨️ 快捷键说明

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