Пример #1
0
  public OrderText() {
    super(pos.posFrame);
    try {
      jbInit();
      setTitle("预订单");
      setSize(350, 200);
      Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
      this.setLocation(
          (int) ((screenSize.getWidth() - 350) / 2), (int) ((screenSize.getHeight() - 200) / 2));

      addKeyAndContainerListenerRecursively(this);

      kmap = PosKeyMap.getInstance();

      this.addWindowListener(
          new WindowAdapter() {
            public void windowClosing(WindowEvent e) {
              cancel();
            }
          });

    } catch (Exception e) {
      e.printStackTrace();
    }
  }
Пример #2
0
 /** 用户按取消键的处理方法 */
 private void cancel() {
   if (posOutputStream != null) {
     try {
       int keyCode = kmap.getKeyValue(new PosInput(PosFunction.CANCEL));
       posOutputStream.write(keyCode);
       posOutputStream.flush();
     } catch (IOException ex) {
       ex.printStackTrace();
     }
   }
 }