📄 clearancedeliverypanel.java.svn-base
字号:
package gui;import javax.swing.*;import javax.swing.event.ListSelectionEvent;import javax.swing.event.ListSelectionListener;import world.*;import java.awt.*;import java.awt.event.*;import java.util.ArrayList;public class ClearanceDeliveryPanel extends JPanel implements ListSelectionListener { // constant variables private final int MAX_HEIGHT = 500; private final int MAX_FLIGHT_WIDTH = 150; private final int MAX_DESTINATION_WIDTH = 150; private final int MAX_PROCEDURE_WIDTH = 150; private final int MAX_TRANSITION_WIDTH = 150; private final int X_PADDING = 0; private final int Y_PADDING = 0; // variables public int indexFlight, indexDestination; public JList flight, destination, gate; public DefaultListModel listFlight, listDestination, listGate; private JLabel labelFlight, labelDestination, labelGate; public JScrollPane scrollFlight, scrollDestination, scrollGate; public JButton buttonApprove; // default constructor public ClearanceDeliveryPanel() { // initialize setLayout(new GridBagLayout()); listFlight = new DefaultListModel(); listGate = new DefaultListModel(); listDestination = new DefaultListModel(); flight = new JList(listFlight); gate = new JList(listGate); destination = new JList(listDestination); labelFlight = new JLabel("Flight"); labelGate = new JLabel("Gate"); labelDestination = new JLabel("Destination"); scrollFlight = new JScrollPane(flight); scrollGate = new JScrollPane(gate); scrollDestination = new JScrollPane(destination); buttonApprove = new JButton("Send Approval"); scrollFlight.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); scrollGate.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); scrollDestination.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); scrollFlight.setPreferredSize(new Dimension(MAX_FLIGHT_WIDTH, MAX_HEIGHT)); scrollGate.setPreferredSize(new Dimension(MAX_FLIGHT_WIDTH, MAX_HEIGHT)); scrollDestination.setPreferredSize(new Dimension(MAX_DESTINATION_WIDTH, MAX_HEIGHT)); flight.addListSelectionListener(this); gate.addListSelectionListener(this); destination.addListSelectionListener(this); flight.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); gate.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); destination.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); // build panel buildPanel(); } // builds panels private void buildPanel() { GridBagConstraints c = new GridBagConstraints(); c.fill = GridBagConstraints.BOTH; c.gridx = 0; c.gridy = 0; //c.anchor = GridBagConstraints.CENTER; //c.insets = new Insets(0,0,Y_PADDING,X_PADDING); add(labelFlight,c); c.fill = GridBagConstraints.BOTH; c.gridx = 1; c.gridy = 0; //c.insets = new Insets(0,0,Y_PADDING,0); add(labelDestination,c); c.fill = GridBagConstraints.BOTH; c.gridx = 0; c.gridy = 1; c.insets = new Insets(0,0,0,X_PADDING); add(scrollFlight,c); c.fill = GridBagConstraints.BOTH; c.gridx = 1; c.gridy = 1; //c.insets = new Insets(0,0,0,X_PADDING); add(scrollDestination,c); c.fill = GridBagConstraints.BOTH; c.gridx = 2; c.gridy = 0; //c.insets = new Insets(0,0,0,0); add(buttonApprove, c); } public void addFlight(String callNumber) { listFlight.addElement(callNumber); } public void setDestinations(String[] destinations) { for(int i = 0; i < destinations.length; i++) { listDestination.addElement(destinations[i]); } } public void valueChanged(ListSelectionEvent e) { if (e.getValueIsAdjusting() == true) { indexFlight = flight.getSelectedIndex(); indexDestination = destination.getSelectedIndex(); } }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -