📄 gui.java.svn-base
字号:
package gui;import java.util.*;import java.awt.*;import java.awt.event.*;import javax.swing.*;import world.*;import agents.*;import base.*;import interfaces.*;public class GUI { private static class GuiLoader extends JPanel implements ActionListener { JButton newLayout, loadLayout; JCheckBox userControlled, cdControlled, lcControlled, gcControlled; AirportBuilder airportBuilder; JFrame guiLoaderFrame; public GuiLoader(AirportBuilder airportBuilder, JFrame guiLoaderFrame) { this.airportBuilder = airportBuilder; this.guiLoaderFrame = guiLoaderFrame; JPanel imagePanel = new JPanel(); JPanel buttonPanel = new JPanel(); JPanel labelPanel = new JPanel(); JPanel checkPanel = new JPanel(); ImageIcon image = new ImageIcon("resources/faaStartUp.jpg"); JLabel label = new JLabel(image, JLabel.CENTER); imagePanel.add(label); newLayout = new JButton("Create new airport"); newLayout.addActionListener(this); loadLayout = new JButton("Load last airport"); loadLayout.addActionListener(this); buttonPanel.add(newLayout); buttonPanel.add(loadLayout); userControlled = new JCheckBox("User controlled?"); userControlled.setSelected(true); // labelPanel.add(userControlledLabel); cdControlled = new JCheckBox("Clearance Delivery"); lcControlled = new JCheckBox("Local Control"); gcControlled = new JCheckBox("Ground Control"); checkPanel.add(cdControlled); checkPanel.add(lcControlled); checkPanel.add(gcControlled); checkPanel.add(userControlled); setLayout(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); c.fill = GridBagConstraints.HORIZONTAL; c.gridx = 0; c.gridy = 0; //c.ipady = 500; add(imagePanel, c); c.fill = GridBagConstraints.HORIZONTAL; //c.ipady = 0; //c.weighty = 1.0; c.gridx = 0; c.gridy = 1; add(buttonPanel, c); c.fill = GridBagConstraints.HORIZONTAL; c.gridx = 0; c.gridy = 2; //c.weighty = 1.0; add(labelPanel, c); c.fill = GridBagConstraints.HORIZONTAL; c.gridx = 0; c.gridy = 3; add(checkPanel, c); } public void actionPerformed(ActionEvent e) { airportBuilder.setUserControlled(userControlled.isSelected(),cdControlled.isSelected(), gcControlled.isSelected(), lcControlled.isSelected()); if(e.getSource() == newLayout) { newLayout.setEnabled(false); airportBuilder.setVisible(true); guiLoaderFrame.setVisible(false); } else if(e.getSource() == loadLayout) { loadLayout.setEnabled(false); if(airportBuilder.loadLayout()) { guiLoaderFrame.setVisible(false); } else { loadLayout.setEnabled(false); } } } } public static void main(String[] args) { AirportBuilder airportBuilder = new AirportBuilder(); airportBuilder.setSize(1400, 700); airportBuilder.setLocation(20, 0); airportBuilder.setVisible(false); JFrame guiLoaderFrame = new JFrame(); GuiLoader guiLoader = new GuiLoader(airportBuilder, guiLoaderFrame); guiLoaderFrame.add(guiLoader); guiLoaderFrame.setSize(720, 640); guiLoaderFrame.setLocation(100, 50); guiLoaderFrame.setVisible(true); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -