- import java.awt.*;
- import java.awt.event.*;
- class JianPanDemo
- {
- public static void main(String[] args)
- { Frame f = new Frame("my awt");
- f.setSize(500,400);
- f.setLocation(300,200);
- f.setLayout(new FlowLayout());
-
- Button b = new Button("按钮");
- f.add(b);
- TextField tf = new TextField(20);
- f.add(tf);
- f.setVisible(true);
- f.addWindowListener(new WindowAdapter(){
- public void windowClosing(WindowEvent e )
- {
- System.exit(0);
- }
-
-
- });
- tf.addKeyListener(new KeyAdapter(){
- public void keyPerssed(KeyEvent e)
- { int con = e.getKeyCode();
- if(!(con>=KeyEvent.VK_0 && con<= KeyEvent.VK_9))
- System.out.println(con+"shi fei fa de ");
-
- }
-
- });
- }
复制代码
|
|