Example #1
0
  public ShenPiPanel(MainFrame par) {
    this.parent = par;

    initUI();
    setHotKey();

    initBL();

    approvebt.addActionListener(this);
    disappbt.addActionListener(this);
    refreshbt.addActionListener(this);
    refreshList();
  }
Example #2
0
 private void initSetBtn(PanelConfig cfg) {
   this.setBtn = new MyButton(cfg.getButtons().element("setting"));
   setBtn.addActionListener(
       new ActionListener() {
         @Override
         public void actionPerformed(ActionEvent e) {
           loginSettingDialog =
               new LoginSettingDialog(ERPConfig.getLOGINSETTING_DIALOG_CONFIG(), frame);
           loginSettingDialog.setVisible(true);
         }
       });
 }
Example #3
0
  public BankAccountPanel(MainFrame par) {
    this.parent = par;
    this.setOpaque(false);
    this.setBorder(
        BorderFactory.createTitledBorder(
            BorderFactory.createBevelBorder(ALLBITS),
            "银行账户",
            TitledBorder.LEFT,
            TitledBorder.TOP,
            new Font("", Font.BOLD, 25)));

    initUI();
    setHotKey();

    addbt.addActionListener(this);
    deletebt.addActionListener(this);
    refreshbt.addActionListener(this);

    initBL();
    refresh();
  }
Example #4
0
  /** Creating buttons with coordinates and action listeners */
  private MyButton createButton() {
    // The new buttons counters -
    // will be translates to coordinates
    if (counterX >= size) {
      counterX = 0;
      counterY++;
    }

    MyButton button = new MyButton();

    // set buttons coordinates
    button.x = counterX++;
    button.y = counterY;

    // The buttons properties adjustment
    button.setPreferredSize(new Dimension(50, 50));
    button.setFont(new Font("Dialog", Font.PLAIN, 72));

    // Action listener
    button.addActionListener(
        e -> {
          game.move(new Move(button.x, button.y));
          game.isGameOver();
          button.setText(game.getField()[button.x][button.y] > 0 ? "X" : "O");
          button.setEnabled(false);
          statusStr.setText(game.getState().toString());

          // If the game is over
          // disable all unselected buttons
          if (game.getState().equals(GameState.X_WINS)
              || game.getState().equals(GameState.O_WINS)) {

            for (Component b : gameField.getComponents()) {
              b.setEnabled(false);
            }
          }
        });

    // System.out.println("button " + button.x + " " + button.y);

    return button;
  }