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

📄 doorpanel.java

📁 这是我们专业的课程设计
💻 JAVA
字号:
package userClient;

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.border.*;
//import Data.*;
import Extend.*;

@SuppressWarnings("serial")
public class DoorPanel extends JPanel implements ActionListener {
	
   	Person ppp;
   	
	@SuppressWarnings("unused")
	private XYClient DoorPanelxy;
	private int elevatorid;
    private boolean change = false;
    
    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 + "");
    	
    	repaint();
    }
    
    public boolean getChange() {
    	return change;
    }
    
    //门打开超过50%后,用户可以进入电梯内
    public void actionPerformed(ActionEvent e) {
    	if (e.getSource() == come && door.getPercent() >= 50 && door.getPercent() <= 100 ) {
    		change = true;
    		
    		ppp.setOnWhichElevator(elevatorid);
    		ppp.setInDoor(true);
    	}
    }
    
    public DoorPanel(int elevatorid,int upOrDown, int onWhichFloor,Person ppp,XYClient DoorPanelxy) {
    	
    	
    	setBorder(new TitledBorder(""));
    	
    	this.elevatorid = elevatorid;
    	this.DoorPanelxy = DoorPanelxy;
    	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("IN" + "");
    	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 + -