📄 indoorpanel.java
字号:
package userClient;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
//import Data.*;
import Extend.*;
@SuppressWarnings("serial")
public class InDoorPanel extends JPanel implements ActionListener {
Person ppp;
@SuppressWarnings("unused")
private XYClient InDoorPanelxy;
@SuppressWarnings("unused")
private int elevatorid;
private boolean change = true;
Door door = new Door();
private JLabel up = new JLabel();
private JLabel down = new JLabel();
private JButton floor = new JButton();
private JPanel panelNorth = new JPanel();
private JPanel panelSouth = new JPanel();
private JButton come = new JButton();
public void setUpOrDown(int upOrDown) {
if (upOrDown == 1) {
up.setIcon(new ImageIcon("image/arrowUp.png"));
down.setIcon(new ImageIcon("image/down.png"));
}
else if (upOrDown == -1) {
up.setIcon(new ImageIcon("image/up.png"));
down.setIcon(new ImageIcon("image/arrowDown.png"));
}
else if (upOrDown == 0 || upOrDown == 2 || upOrDown == -2) {
up.setIcon(new ImageIcon("image/up.png"));
down.setIcon(new ImageIcon("image/down.png"));
}
repaint();
}
public void setFloor(int onWhichFloor) {
floor.setFont(new Font("",Font.BOLD,20));
floor.setBackground(Color.LIGHT_GRAY);
floor.setForeground(Color.RED);
floor.setText(onWhichFloor + "");
ppp.setOnWhichFloor(onWhichFloor);
repaint();
}
public boolean getChange() {
return change;
}
public void actionPerformed(ActionEvent e) {
if (e.getSource() == come && door.getPercent() >= 50 && door.getPercent() <= 100) {
change = false;
ppp.setInDoor(false);
ppp.setOnWhichElevator(-1);
}
}
public void setPerson(Person pp){
ppp = pp;
}
public void setXYClient(XYClient xx){
InDoorPanelxy = xx;
}
//it is this time to know the elevator ID
public void setElevatorID(int abc){
elevatorid = abc;
}
public InDoorPanel(int elevatorid,int upOrDown, int onWhichFloor,Person ppp,XYClient InDoorPanelxy) {
this.elevatorid = elevatorid;
this.InDoorPanelxy = InDoorPanelxy;
this.ppp = ppp;
setUpOrDown(upOrDown);
setFloor(onWhichFloor);
panelNorth.setLayout(new FlowLayout(FlowLayout.CENTER));
panelNorth.setBackground(Color.LIGHT_GRAY);
panelNorth.add(up);
panelNorth.add(floor);
panelNorth.add(down);
come.setFont(new Font("",Font.BOLD,20));
come.setBackground(Color.LIGHT_GRAY);
come.setForeground(Color.RED);
come.setText("OUT" + "");
come.addActionListener(this);
panelSouth.add(come);
panelSouth.setBackground(Color.LIGHT_GRAY);
setLayout(new BorderLayout(5,5));
setBackground(Color.LIGHT_GRAY);
add(panelNorth, BorderLayout.NORTH);
add(door, BorderLayout.CENTER);
add(panelSouth, BorderLayout.SOUTH);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -