private void addAccelerators(JPanel panel) {
InputMap imap = panel.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
ActionMap amap = panel.getActionMap();
// 开台 (/)
MyKeyBoardAction checkin = new MyKeyBoardAction();
imap.put(KeyStroke.getKeyStroke(KeyEvent.VK_DIVIDE, 0),
"m_rightCustomerCheckIn");
amap.put("m_rightCustomerCheckIn", checkin);
checkin.putValue(AbstractAction.ACTION_COMMAND_KEY,
"m_rightCustomerCheckIn");
// 添加消费(+)
MyKeyBoardAction addspend = new MyKeyBoardAction();
imap.put(KeyStroke.getKeyStroke(KeyEvent.VK_ADD, 0), "m_rightAddSpend");
amap.put("m_rightAddSpend", addspend);
addspend.putValue(AbstractAction.ACTION_COMMAND_KEY, "m_rightAddSpend");
// 客户结账(*)
MyKeyBoardAction checkout = new MyKeyBoardAction();
imap.put(KeyStroke.getKeyStroke(KeyEvent.VK_MULTIPLY, 0),
"m_rightCustomerCheckOut");
amap.put("m_rightCustomerCheckOut", checkout);
checkout.putValue(AbstractAction.ACTION_COMMAND_KEY,
"m_rightCustomerCheckOut");
// 小键盘数字键
// (0)
MyKeyBoardAction o = new MyKeyBoardAction();
imap.put(KeyStroke.getKeyStroke(KeyEvent.VK_NUMPAD0, 0), "0");
amap.put("0", o);
o.putValue(AbstractAction.ACTION_COMMAND_KEY, "0");
// (1)
MyKeyBoardAction one = new MyKeyBoardAction();
imap.put(KeyStroke.getKeyStroke(KeyEvent.VK_NUMPAD1, 0), "1");
amap.put("1", one);
one.putValue(AbstractAction.ACTION_COMMAND_KEY, "1");
// (2)
MyKeyBoardAction tow = new MyKeyBoardAction();
imap.put(KeyStroke.getKeyStroke(KeyEvent.VK_NUMPAD2, 0), "2");
amap.put("2", tow);
tow.putValue(AbstractAction.ACTION_COMMAND_KEY, "2");
// (3)
MyKeyBoardAction three = new MyKeyBoardAction();
imap.put(KeyStroke.getKeyStroke(KeyEvent.VK_NUMPAD3, 0), "3");
amap.put("3", three);
three.putValue(AbstractAction.ACTION_COMMAND_KEY, "3");
// (4)
MyKeyBoardAction four = new MyKeyBoardAction();
imap.put(KeyStroke.getKeyStroke(KeyEvent.VK_NUMPAD4, 0), "4");
amap.put("4", four);
four.putValue(AbstractAction.ACTION_COMMAND_KEY, "4");
// (5)
MyKeyBoardAction five = new MyKeyBoardAction();
imap.put(KeyStroke.getKeyStroke(KeyEvent.VK_NUMPAD5, 0), "5");
amap.put("5", five);
five.putValue(AbstractAction.ACTION_COMMAND_KEY, "5");
// (6)
MyKeyBoardAction six = new MyKeyBoardAction();
imap.put(KeyStroke.getKeyStroke(KeyEvent.VK_NUMPAD6, 0), "6");
amap.put("6", six);
six.putValue(AbstractAction.ACTION_COMMAND_KEY, "6");
// (7)
MyKeyBoardAction seven = new MyKeyBoardAction();
imap.put(KeyStroke.getKeyStroke(KeyEvent.VK_NUMPAD7, 0), "7");
amap.put("7", seven);
seven.putValue(AbstractAction.ACTION_COMMAND_KEY, "7");
// (8)
MyKeyBoardAction eight = new MyKeyBoardAction();
imap.put(KeyStroke.getKeyStroke(KeyEvent.VK_NUMPAD8, 0), "8");
amap.put("8", eight);
eight.putValue(AbstractAction.ACTION_COMMAND_KEY, "8");
// (9)
MyKeyBoardAction nine = new MyKeyBoardAction();
imap.put(KeyStroke.getKeyStroke(KeyEvent.VK_NUMPAD9, 0), "9");
amap.put("9", nine);
nine.putValue(AbstractAction.ACTION_COMMAND_KEY, "9");
// 大键盘数字键
// (0)
MyKeyBoardAction o1 = new MyKeyBoardAction();
imap.put(KeyStroke.getKeyStroke(KeyEvent.VK_0, 0), "0");
amap.put("0", o1);
o1.putValue(AbstractAction.ACTION_COMMAND_KEY, "0");
// (1)
MyKeyBoardAction one1 = new MyKeyBoardAction();
imap.put(KeyStroke.getKeyStroke(KeyEvent.VK_1, 0), "1");
amap.put("1", one1);
one1.putValue(AbstractAction.ACTION_COMMAND_KEY, "1");
// (2)
MyKeyBoardAction tow1 = new MyKeyBoardAction();
imap.put(KeyStroke.getKeyStroke(KeyEvent.VK_2, 0), "2");
amap.put("2", tow1);
tow1.putValue(AbstractAction.ACTION_COMMAND_KEY, "2");
// (3)
MyKeyBoardAction three1 = new MyKeyBoardAction();
imap.put(KeyStroke.getKeyStroke(KeyEvent.VK_3, 0), "3");
amap.put("3", three1);
three1.putValue(AbstractAction.ACTION_COMMAND_KEY, "3");
// (4)
MyKeyBoardAction four1 = new MyKeyBoardAction();
imap.put(KeyStroke.getKeyStroke(KeyEvent.VK_4, 0), "4");
amap.put("4", four1);
four1.putValue(AbstractAction.ACTION_COMMAND_KEY, "4");
// (5)
MyKeyBoardAction five1 = new MyKeyBoardAction();
imap.put(KeyStroke.getKeyStroke(KeyEvent.VK_5, 0), "5");
amap.put("5", five1);
five1.putValue(AbstractAction.ACTION_COMMAND_KEY, "5");
// (6)
MyKeyBoardAction six1 = new MyKeyBoardAction();
imap.put(KeyStroke.getKeyStroke(KeyEvent.VK_6, 0), "6");
amap.put("6", six1);
six1.putValue(AbstractAction.ACTION_COMMAND_KEY, "6");
// (7)
MyKeyBoardAction seven1 = new MyKeyBoardAction();
imap.put(KeyStroke.getKeyStroke(KeyEvent.VK_7, 0), "7");
amap.put("7", seven1);
seven1.putValue(AbstractAction.ACTION_COMMAND_KEY, "7");
// (8)
MyKeyBoardAction eight1 = new MyKeyBoardAction();
imap.put(KeyStroke.getKeyStroke(KeyEvent.VK_8, 0), "8");
amap.put("8", eight1);
eight1.putValue(AbstractAction.ACTION_COMMAND_KEY, "8");
// (9)
MyKeyBoardAction nine1 = new MyKeyBoardAction();
imap.put(KeyStroke.getKeyStroke(KeyEvent.VK_9, 0), "9");
amap.put("9", nine1);
nine1.putValue(AbstractAction.ACTION_COMMAND_KEY, "9");
// (Esc)退出键
MyKeyBoardAction esc = new MyKeyBoardAction();
imap.put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), "esc");
amap.put("esc", esc);
esc.putValue(AbstractAction.ACTION_COMMAND_KEY, "esc");
// (Home)呼出搜索桌台对话框
MyKeyBoardAction home = new MyKeyBoardAction();
imap.put(KeyStroke.getKeyStroke(KeyEvent.VK_HOME, 0), "serchTable");
amap.put("serchTable", home);
home.putValue(AbstractAction.ACTION_COMMAND_KEY, "serchTable");
}
InputMap imap = panel.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
ActionMap amap = panel.getActionMap();
// 开台 (/)
MyKeyBoardAction checkin = new MyKeyBoardAction();
imap.put(KeyStroke.getKeyStroke(KeyEvent.VK_DIVIDE, 0),
"m_rightCustomerCheckIn");
amap.put("m_rightCustomerCheckIn", checkin);
checkin.putValue(AbstractAction.ACTION_COMMAND_KEY,
"m_rightCustomerCheckIn");
// 添加消费(+)
MyKeyBoardAction addspend = new MyKeyBoardAction();
imap.put(KeyStroke.getKeyStroke(KeyEvent.VK_ADD, 0), "m_rightAddSpend");
amap.put("m_rightAddSpend", addspend);
addspend.putValue(AbstractAction.ACTION_COMMAND_KEY, "m_rightAddSpend");
// 客户结账(*)
MyKeyBoardAction checkout = new MyKeyBoardAction();
imap.put(KeyStroke.getKeyStroke(KeyEvent.VK_MULTIPLY, 0),
"m_rightCustomerCheckOut");
amap.put("m_rightCustomerCheckOut", checkout);
checkout.putValue(AbstractAction.ACTION_COMMAND_KEY,
"m_rightCustomerCheckOut");
// 小键盘数字键
// (0)
MyKeyBoardAction o = new MyKeyBoardAction();
imap.put(KeyStroke.getKeyStroke(KeyEvent.VK_NUMPAD0, 0), "0");
amap.put("0", o);
o.putValue(AbstractAction.ACTION_COMMAND_KEY, "0");
// (1)
MyKeyBoardAction one = new MyKeyBoardAction();
imap.put(KeyStroke.getKeyStroke(KeyEvent.VK_NUMPAD1, 0), "1");
amap.put("1", one);
one.putValue(AbstractAction.ACTION_COMMAND_KEY, "1");
// (2)
MyKeyBoardAction tow = new MyKeyBoardAction();
imap.put(KeyStroke.getKeyStroke(KeyEvent.VK_NUMPAD2, 0), "2");
amap.put("2", tow);
tow.putValue(AbstractAction.ACTION_COMMAND_KEY, "2");
// (3)
MyKeyBoardAction three = new MyKeyBoardAction();
imap.put(KeyStroke.getKeyStroke(KeyEvent.VK_NUMPAD3, 0), "3");
amap.put("3", three);
three.putValue(AbstractAction.ACTION_COMMAND_KEY, "3");
// (4)
MyKeyBoardAction four = new MyKeyBoardAction();
imap.put(KeyStroke.getKeyStroke(KeyEvent.VK_NUMPAD4, 0), "4");
amap.put("4", four);
four.putValue(AbstractAction.ACTION_COMMAND_KEY, "4");
// (5)
MyKeyBoardAction five = new MyKeyBoardAction();
imap.put(KeyStroke.getKeyStroke(KeyEvent.VK_NUMPAD5, 0), "5");
amap.put("5", five);
five.putValue(AbstractAction.ACTION_COMMAND_KEY, "5");
// (6)
MyKeyBoardAction six = new MyKeyBoardAction();
imap.put(KeyStroke.getKeyStroke(KeyEvent.VK_NUMPAD6, 0), "6");
amap.put("6", six);
six.putValue(AbstractAction.ACTION_COMMAND_KEY, "6");
// (7)
MyKeyBoardAction seven = new MyKeyBoardAction();
imap.put(KeyStroke.getKeyStroke(KeyEvent.VK_NUMPAD7, 0), "7");
amap.put("7", seven);
seven.putValue(AbstractAction.ACTION_COMMAND_KEY, "7");
// (8)
MyKeyBoardAction eight = new MyKeyBoardAction();
imap.put(KeyStroke.getKeyStroke(KeyEvent.VK_NUMPAD8, 0), "8");
amap.put("8", eight);
eight.putValue(AbstractAction.ACTION_COMMAND_KEY, "8");
// (9)
MyKeyBoardAction nine = new MyKeyBoardAction();
imap.put(KeyStroke.getKeyStroke(KeyEvent.VK_NUMPAD9, 0), "9");
amap.put("9", nine);
nine.putValue(AbstractAction.ACTION_COMMAND_KEY, "9");
// 大键盘数字键
// (0)
MyKeyBoardAction o1 = new MyKeyBoardAction();
imap.put(KeyStroke.getKeyStroke(KeyEvent.VK_0, 0), "0");
amap.put("0", o1);
o1.putValue(AbstractAction.ACTION_COMMAND_KEY, "0");
// (1)
MyKeyBoardAction one1 = new MyKeyBoardAction();
imap.put(KeyStroke.getKeyStroke(KeyEvent.VK_1, 0), "1");
amap.put("1", one1);
one1.putValue(AbstractAction.ACTION_COMMAND_KEY, "1");
// (2)
MyKeyBoardAction tow1 = new MyKeyBoardAction();
imap.put(KeyStroke.getKeyStroke(KeyEvent.VK_2, 0), "2");
amap.put("2", tow1);
tow1.putValue(AbstractAction.ACTION_COMMAND_KEY, "2");
// (3)
MyKeyBoardAction three1 = new MyKeyBoardAction();
imap.put(KeyStroke.getKeyStroke(KeyEvent.VK_3, 0), "3");
amap.put("3", three1);
three1.putValue(AbstractAction.ACTION_COMMAND_KEY, "3");
// (4)
MyKeyBoardAction four1 = new MyKeyBoardAction();
imap.put(KeyStroke.getKeyStroke(KeyEvent.VK_4, 0), "4");
amap.put("4", four1);
four1.putValue(AbstractAction.ACTION_COMMAND_KEY, "4");
// (5)
MyKeyBoardAction five1 = new MyKeyBoardAction();
imap.put(KeyStroke.getKeyStroke(KeyEvent.VK_5, 0), "5");
amap.put("5", five1);
five1.putValue(AbstractAction.ACTION_COMMAND_KEY, "5");
// (6)
MyKeyBoardAction six1 = new MyKeyBoardAction();
imap.put(KeyStroke.getKeyStroke(KeyEvent.VK_6, 0), "6");
amap.put("6", six1);
six1.putValue(AbstractAction.ACTION_COMMAND_KEY, "6");
// (7)
MyKeyBoardAction seven1 = new MyKeyBoardAction();
imap.put(KeyStroke.getKeyStroke(KeyEvent.VK_7, 0), "7");
amap.put("7", seven1);
seven1.putValue(AbstractAction.ACTION_COMMAND_KEY, "7");
// (8)
MyKeyBoardAction eight1 = new MyKeyBoardAction();
imap.put(KeyStroke.getKeyStroke(KeyEvent.VK_8, 0), "8");
amap.put("8", eight1);
eight1.putValue(AbstractAction.ACTION_COMMAND_KEY, "8");
// (9)
MyKeyBoardAction nine1 = new MyKeyBoardAction();
imap.put(KeyStroke.getKeyStroke(KeyEvent.VK_9, 0), "9");
amap.put("9", nine1);
nine1.putValue(AbstractAction.ACTION_COMMAND_KEY, "9");
// (Esc)退出键
MyKeyBoardAction esc = new MyKeyBoardAction();
imap.put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), "esc");
amap.put("esc", esc);
esc.putValue(AbstractAction.ACTION_COMMAND_KEY, "esc");
// (Home)呼出搜索桌台对话框
MyKeyBoardAction home = new MyKeyBoardAction();
imap.put(KeyStroke.getKeyStroke(KeyEvent.VK_HOME, 0), "serchTable");
amap.put("serchTable", home);
home.putValue(AbstractAction.ACTION_COMMAND_KEY, "serchTable");
}