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

📄 elevator.txt

📁 电梯模拟
💻 TXT
字号:
import java.awt.*;
import java.awt.event.*;

import javax.swing.*;
import javax.swing.border.TitledBorder;

public class Elevator extends JFrame implements ActionListener{
	private static final long serialVersionUID = 1L;
	
	public static void main(String[] args){
		Elevator frame = new Elevator();
		frame.setTitle("Elevator");
		frame.setSize(600, 400);
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		frame.setResizable(false);
		frame.setVisible(true);
	}
	
	JPanel panel1=new JPanel();
	JPanel panel2=new JPanel();
	JPanel panel3=new JPanel();
	JPanel panel4=new JPanel();
	JPanel panel5=new JPanel();
	JPanel panel6=new JPanel();
	JPanel panel7=new JPanel();
	JPanel panel8=new JPanel();
	JPanel panel9=new JPanel();
	JPanel panel10=new JPanel();
	JPanel panel11=new JPanel();
	JPanel panel12=new JPanel();
	

	JButton b1=new JButton("1");
	JButton b2=new JButton("2");
	JButton b3=new JButton("3");
	JButton b4=new JButton("4");
	JButton b5=new JButton("5");
	JButton b6=new JButton("6");
	JButton b7=new JButton("7");
	JButton b8=new JButton("8");
	JButton b9=new JButton("9");
	JButton b10=new JButton("10");
	
	JButton b11=new JButton("1");
	
	JButton bo=new JButton("<||>");
	JButton bc=new JButton("|><|");
	
	JLabel l1 =new JLabel();
	JLabel l2 =new JLabel();
	JLabel l4 =new JLabel();
	
	JButton bClock=new JButton("BAOJING");
	
	Door door=new Door();
	
	public Elevator(){
		b1.setBackground(Color.black);
		b1.setForeground(Color.white);
		b2.setBackground(Color.black);
		b2.setForeground(Color.white);
		b3.setBackground(Color.black);
		b3.setForeground(Color.white);
		b4.setBackground(Color.black);
		b4.setForeground(Color.white);
		b5.setBackground(Color.black);
		b5.setForeground(Color.white);
		b6.setBackground(Color.black);
		b6.setForeground(Color.white);
		b7.setBackground(Color.black);
		b7.setForeground(Color.white);
		b8.setBackground(Color.black);
		b8.setForeground(Color.white);
		b9.setBackground(Color.black);
		b9.setForeground(Color.white);
		b10.setBackground(Color.black);
		b10.setForeground(Color.white);
		bo.setBackground(Color.black);
		bo.setForeground(Color.white);
		bc.setBackground(Color.black);
		bc.setForeground(Color.white);
		bClock.setBackground(Color.black);
		
		bo.addActionListener(this);
		
		panel1.setLayout(new GridLayout(4,3));
		panel1.add(b1);
		panel1.add(b2);
		panel1.add(b3);
		panel1.add(b4);
		panel1.add(b5);
		panel1.add(b6);
		panel1.add(b7);
		panel1.add(b8);
		panel1.add(b9);
		panel1.add(b10);
		panel1.add(bo);
		panel1.add(bc);
		panel1.setBorder(new TitledBorder(""));
		
		l1.setIcon(new ImageIcon("D:/ѧϰ/JAVA/workspace/exercise/2006413161814659.PNG"));
		l2.setIcon(new ImageIcon("D:/ѧϰ/JAVA/workspace/exercise/ii.PNG"));
		b11.setFont(new Font("",Font.BOLD,20));
		b11.setBackground(Color.black);
		b11.setForeground(Color.RED);
		l4.setIcon(new ImageIcon("D:/ѧϰ/JAVA/workspace/exercise/s.gif"));
		
		panel2.setBackground(Color.LIGHT_GRAY);
		panel3.setBackground(Color.LIGHT_GRAY);
		panel4.setBackground(Color.LIGHT_GRAY);
		panel5.setBackground(Color.LIGHT_GRAY);
		panel6.setBackground(Color.LIGHT_GRAY);
		panel7.setBackground(Color.LIGHT_GRAY);
		panel8.setBackground(Color.LIGHT_GRAY);
		panel9.setBackground(Color.LIGHT_GRAY);
		panel10.setBackground(Color.LIGHT_GRAY);
		panel11.setBackground(Color.LIGHT_GRAY);
		panel12.setBackground(Color.LIGHT_GRAY);
		
		panel2.setLayout(new FlowLayout(FlowLayout.LEFT,35,20));
		panel2.add(l1);
		panel2.add(b11);
		panel2.add(l2);
		
		panel3.setLayout(new BorderLayout(5,5));
		panel3.add(panel2,BorderLayout.NORTH);
		panel3.add(door,BorderLayout.CENTER);
		
		panel4.setLayout(new BorderLayout(100,10));
		panel4.add(l4,BorderLayout.WEST);
		panel4.add(bClock,BorderLayout.CENTER);
		panel4.add(panel6,BorderLayout.EAST);
		
		panel8.setLayout(new BorderLayout(100,20));
		panel8.add(panel1,BorderLayout.NORTH);
		panel8.add(panel9,BorderLayout.SOUTH);
		panel8.add(panel11,BorderLayout.CENTER);
		
		panel12.setLayout(new BorderLayout(5,5));
		panel12.add(panel4,BorderLayout.NORTH);
		panel12.add(panel8,BorderLayout.CENTER);
		
		panel10.setLayout(new BorderLayout(0,0));
		panel10.add(panel3,BorderLayout.CENTER);
		panel10.add(panel12,BorderLayout.EAST);
		
		getContentPane().setLayout(new BorderLayout(10,5));
		getContentPane().add(panel10,BorderLayout.CENTER);
		
		
	}
	
	public void actionPerformed(ActionEvent e){
		
	}
	
	
}

⌨️ 快捷键说明

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