import javax.swing.*; import java.awt.*; import java.awt.event.*; public class KeyerClicker { static JButton button = new JButton (""); public static void main (String[] args) { JFrame frame = new JFrame ("KeyerClicker"); frame.getContentPane().add (button, BorderLayout.CENTER); button.addActionListener (new ActionListener() { public void actionPerformed (ActionEvent e) { button.setText ("click"); } }); button.addKeyListener (new KeyAdapter() { public void keyTyped (KeyEvent e) { char c = e.getKeyChar(); button.setText (String.valueOf (c)); } }); button.requestFocusInWindow (); frame.addWindowListener(new WindowAdapter() { public void windowClosing (WindowEvent e) { System.exit(0); } }); frame.pack (); frame.setVisible(true); } }