/**************************************** * * This program can be used to view the current * setting of the PlayStation controller buttons * ****************************************/ import java.awt.*; import java.awt.event.*; import javax.swing.*; class Calibrate { // Global Items public JFrame window = null; public WListener wl = null; public KListener kl = null; public JLabel textPane = null; public JPanel cp = null; public Font f = null; // Constructor for the class // Creates window & components, adds listeners public Calibrate() { cp = new JPanel(); f = new Font("Arial",1,26); textPane = new JLabel(); textPane.setText("Press Button"); textPane.setFont(f); wl = new WListener(this); kl = new KListener(this); window = new JFrame("PSX2USB Calibrator"); window.pack(); window.setSize(220,100); window.setContentPane(cp); cp.add(textPane); window.addWindowListener(wl); window.addKeyListener(kl); window.setEnabled(true); window.setVisible(true); } // Main function - call constructor to start program public static void main(String[] args) { Calibrate c = new Calibrate(); } } // Adds Windowadapter to check for window events class WListener extends WindowAdapter{ public Calibrate program=null; public WListener(Calibrate c) { program = c; } public void windowClosing(WindowEvent we) { System.out.println("Got closing event."); program.window.dispose(); System.exit(0); } } // Adds Keyadapter to check for key events class KListener extends KeyAdapter{ public Calibrate program=null; public KListener(Calibrate c) { program = c; } public void keyPressed(KeyEvent ke) { if(ke.getKeyCode() == KeyEvent.VK_CAPS_LOCK ){ program.textPane.setText("CapsLock"); return; } program.textPane.setText(ke.getKeyChar()+""); } }