forked from patniemeyer/learningjava
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDynamicHookup.java
More file actions
29 lines (25 loc) · 820 Bytes
/
Copy pathDynamicHookup.java
File metadata and controls
29 lines (25 loc) · 820 Bytes
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
//file: DynamicHookup.java
import javax.swing.*;
import java.awt.event.*;
import java.beans.EventHandler;
public class DynamicHookup extends JFrame {
JLabel label = new JLabel( "Ready...", JLabel.CENTER );
int count;
public DynamicHookup() {
JButton launchButton = new JButton("Launch!");
getContentPane().add( launchButton, "South" );
getContentPane().add( label, "Center" );
launchButton.addActionListener(
(ActionListener)EventHandler.create(
ActionListener.class, this, "launchTheMissiles"));
}
public void launchTheMissiles() {
label.setText("Launched: "+ count++ );
}
public static void main( String[] args ) {
JFrame frame = new DynamicHookup();
frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
frame.setSize(150, 150);
frame.setVisible( true );
}
}