Ver Mensaje Individual
  #6 (permalink)  
Antiguo 09/10/2014, 07:48
Avatar de Profesor_Falken
Profesor_Falken
 
Fecha de Ingreso: agosto-2014
Ubicación: Mountain View
Mensajes: 1.323
Antigüedad: 10 años, 6 meses
Puntos: 182
Respuesta: Aplicación java con interfaz antigua?

MouseListener?????????????????????????????


Código Java:
Ver original
  1. class MyPanel extends JPanel implements KeyListener {
  2.     private char c = 'e';
  3.  
  4.     public MyPanel() {
  5.         this.setPreferredSize(new Dimension(500, 500));
  6.         addKeyListener(this);
  7.     }
  8.  
  9.     public void addNotify() {
  10.         super.addNotify();
  11.         requestFocus();
  12.     }
  13.  
  14.     public void paintComponent(Graphics g) {
  15.         g.clearRect(0, 0, getWidth(), getHeight());
  16.         g.drawString("the key that pressed is " + c, 250, 250);
  17.     }
  18.  
  19.     public void keyPressed(KeyEvent e) { }
  20.     public void keyReleased(KeyEvent e) { }
  21.     public void keyTyped(KeyEvent e) {
  22.         c = e.getKeyChar();
  23.         repaint();
  24.     }
  25.  
  26.     public static void main(String[] s) {
  27.         JFrame f = new JFrame();
  28.         f.getContentPane().add(new MyPanel());
  29.         f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  30.         f.pack();
  31.         f.setVisible(true);
  32.     }
  33. }

http://docs.oracle.com/javase/tutori...ylistener.html
__________________
If to err is human, then programmers are the most human of us