/* * Copyright 2006 (C) Jeffrey Palm * * This code is licensed under the GPL. */ import java.awt.*; import java.awt.event.*; import java.awt.datatransfer.*; import javax.swing.*; import javax.swing.event.*; import java.io.*; /** * A simple class to display a keyboard that copies keystrokes * to the clipboard so that if your keyboard dies you can still * type. * * @author Jeffrey Palm */ public class Keyboard { public static void main(String[] args) { new Keyboard().realMain(args); } void realMain(String[] args) { // // The gui stuff // final TextTransfer tt = new TextTransfer(); final JLabel contents = new JLabel(tt.getClipboardContents()); JFrame f = new JFrame("Keyboard"); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.getContentPane().setLayout(new BoxLayout(f.getContentPane(),BoxLayout.Y_AXIS)); JPanel p; // we'll reuse this p = newPanel(); p.add(new JLabel("Contents: ")); p.add(contents); f.getContentPane().add(p); final JCheckBox caps = new JCheckBox("Caps"); final boolean[] checked = new boolean[1]; caps.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { checked[0] = e.getStateChange() == ItemEvent.SELECTED; } }); char[][] keys = { {'~','!','@','#','$','%','^','&','*','(','0','_','+'}, {'`','1','2','3','4','5','6','7','8','9','0','-','='}, {'Q','W','E','R','T','Y','U','I','O','P','[','{',']','}'}, {'A','S','D','F','G','H','J','K','L',';',':','\'','"',','}, {'Z','X','C','V','B','N','M',',','<','.','>','/','?'} }; for (int i=0; i