📄 mainframe.java~44~
字号:
package elevator;import java.awt.*;import java.awt.event.*;import javax.swing.*;import com.borland.jbcl.layout.*;import java.io.*;/** * <p>Title: </p> * <p>Description: </p> * <p>Copyright: Copyright (c) 2002</p> * <p>Company: </p> * @author unascribed * @version 1.0 */public class MainFrame extends JFrame { private JPanel contentPane; private XYLayout xYLayout1 = new XYLayout(); private JButton Start = new JButton(); private JButton Stop = new JButton(); private Person person= new Person(); private elevator elevat=new elevator(); private JTextField floor2 = new JTextField(); private JTextField floor1 = new JTextField(); private JButton requestButton = new JButton(); //Construct the frame public MainFrame() { enableEvents(AWTEvent.WINDOW_EVENT_MASK); try { jbInit(); } catch(Exception e) { e.printStackTrace(); } } //Component initialization private void jbInit() throws Exception { //setIconImage(Toolkit.getDefaultToolkit().createImage(MainFrame.class.getResource("[Your Icon]"))); contentPane = (JPanel) this.getContentPane(); Start.setText("Start"); Start.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { Start_actionPerformed(e); } }); contentPane.setLayout(xYLayout1); this.setSize(new Dimension(423, 331)); this.setTitle("Frame Title"); Stop.setText("Stop"); Stop.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { Stop_actionPerformed(e); } }); floor2.setBackground(Color.lightGray); floor2.setBorder(null); floor1.setBorder(null); floor1.setBackground(Color.lightGray); requestButton.setBackground(Color.gray); requestButton.setBorder(BorderFactory.createEtchedBorder()); elevat.setBorder(BorderFactory.createRaisedBevelBorder()); person.setOpaque(false); contentPane.add(Start, new XYConstraints(23, 11, -1, -1)); contentPane.add(Stop, new XYConstraints(132, 11, -1,-1)); contentPane.add(floor2, new XYConstraints(43, 159, 381, 15)); contentPane.add(floor1, new XYConstraints(37, 300, 381, 15)); contentPane.add(person, new XYConstraints(35, 259, 50, 50)); contentPane.add(requestButton, new XYConstraints(254, 230, 18, 19)); contentPane.add(elevat, new XYConstraints(295, 56, 82, 104)); } //Overridden so we can exit when window is closed protected void processWindowEvent(WindowEvent e) { super.processWindowEvent(e); if (e.getID() == WindowEvent.WINDOW_CLOSING) { System.exit(0); } } void Start_actionPerformed(ActionEvent e) { PersonThread pt=new PersonThread(person,elevat,requestButton); pt.setPriority(Thread.NORM_PRIORITY ); pt.start(); } void Stop_actionPerformed(ActionEvent e) { person.setLocation(23,83) ; elevat.open() ; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -