forked from Cameron92/ProjectJava
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathKeyapp.java
More file actions
53 lines (43 loc) · 1.04 KB
/
Copy pathKeyapp.java
File metadata and controls
53 lines (43 loc) · 1.04 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
//craig comment.
//this is a comment.
package prog24178;
//this is a test
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JTextField;
import java.awt.*;
import java.awt.event.*;
import javax.swing.JSlider;
//hello
public class KeyApp extends JFrame implements KeyListener{
Container c;
JTextField txt;
public KeyApp(){
super ("Key Listener Example");
c = getContentPane();
getContentPane().setLayout(null);
JSlider slider = new JSlider();
slider.setBounds(114, 193, 200, 26);
getContentPane().add(slider);
txt = new JTextField(12);
txt.setBounds(59, 11, 314, 20);
c.add(txt);
txt.addKeyListener(this);
}
public static void main(String[] args) {
KeyApp app = new KeyApp();
app.setSize(300, 200);
app.setVisible(true);
app.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
}
@Override
public void keyPressed(KeyEvent e) {
JOptionPane.showMessageDialog(this, e.getKeyCode());
}
@Override
public void keyReleased(KeyEvent e) {
}
@Override
public void keyTyped(KeyEvent e) {
}
}