📄 flightreservation.java
字号:
import java.awt.*;import java.awt.event.*;import javax.swing.*;import javax.swing.border.*;import javax.swing.event.*;public class FlightReservation extends JFrame { public FlightReservation() { super("Flight Reservation Dialog"); setSize(400, 300); JPanel p1 = new JPanel(); p1.setLayout(new BoxLayout(p1, BoxLayout.X_AXIS)); JPanel p1r = new JPanel(); p1r.setBorder(new EmptyBorder(10,10,10,10)); JPanel p11 = new JPanel(); p11.setLayout(new GridLayout(3, 1)); JPanel p12 = new JPanel(); p12.setLayout(new GridLayout(3, 1)); p11.add(new JLabel("Date:")); p12.add(new JTextField()); p11.add(new JLabel("From:")); JComboBox cb1 = new JComboBox(); cb1.addItem("Kuala Lumpur"); cb1.addItem("Johor"); cb1.addItem("Penang"); cb1.addItem("Melaka"); p12.add(cb1); p11.add(new JLabel("To:")); JComboBox cb2 = new JComboBox(); cb2.addItem("Melaka"); cb2.addItem("Penang"); cb2.addItem("Johor"); cb2.addItem("Kuala Lumpur"); p12.add(cb2); p1r.setLayout(new BorderLayout()); p1r.add(p11, BorderLayout.WEST); p1r.add(p12, BorderLayout.CENTER); p1.add(p1r); JPanel p3 = new JPanel(); p3.setLayout(new GridLayout(3, 1)); p3.setBorder(new TitledBorder("Options")); ButtonGroup group = new ButtonGroup(); JRadioButton r1 = new JRadioButton("First class"); group.add(r1); p3.add(r1); JRadioButton r2 = new JRadioButton("Business"); group.add(r2); p3.add(r2); JRadioButton r3 = new JRadioButton("Economy"); group.add(r3); p3.add(r3); p1.add(p3); getContentPane().add(p1, BorderLayout.NORTH); JPanel p2 = new JPanel(new BorderLayout()); p2.setBorder(new TitledBorder("Available Flights")); JTextArea text = new JTextArea(); JScrollPane ps = new JScrollPane(text); p2.add(ps, BorderLayout.CENTER); getContentPane().add(p2, BorderLayout.CENTER); JPanel p4 = new JPanel(); JPanel p4c = new JPanel(); p4c.setLayout(new GridLayout(1, 3)); JButton b1 = new JButton("Search"); p4c.add(b1); JButton b2 = new JButton("Purchase"); p4c.add(b2); JButton b3 = new JButton("Exit"); p4c.add(b3); p4.add(p4c); getContentPane().add(p4, BorderLayout.SOUTH); } public static void main(String argv[]) { FlightReservation frame = new FlightReservation(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); //Version 1.3 frame.show(); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -