-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFindAirportFrame.java
More file actions
65 lines (51 loc) · 1.67 KB
/
FindAirportFrame.java
File metadata and controls
65 lines (51 loc) · 1.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTextField;
public class FindAirportFrame extends JFrame {
private JPanel panel;
private JButton FindButton,VisualizeButton;
private JTextField findfield;
public FindAirportFrame() {
panel = new JPanel();
findfield=new JTextField("City name: ", 15);
FindButton= new JButton("Find");
VisualizeButton= new JButton("Visualize Network");
panel.add(findfield);
panel.add(FindButton);
panel.add(VisualizeButton);
findfield.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
findfield.setText("");
}
});//when findfield is initially clicked on, text area will be cleared
FindButton.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e) {
String city = findfield.getText();
Airport airportx=CentralRegistry.getAirport(city);
if (airportx!=null)
new AirportPageFrame(airportx);
else
JOptionPane.showMessageDialog(null,city+" does not have an airport");
}
}
);
VisualizeButton.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e) {
new VisFrame(CentralRegistry.getFlights());
}
}
);
this.setContentPane(panel);
this.setVisible(true);
this.setSize(300,400);
this.setTitle("Find Airport");
this.setDefaultCloseOperation(EXIT_ON_CLOSE);
}
}