public ShenPiPanel(MainFrame par) { this.parent = par; initUI(); setHotKey(); initBL(); approvebt.addActionListener(this); disappbt.addActionListener(this); refreshbt.addActionListener(this); refreshList(); }
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); } }); }
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(); }
/** 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; }
private void setupPanels() { Border border1, border2; int row, col; MyButton btn; border2 = BorderFactory.createLoweredBevelBorder(); JPanel mainPanel = new JPanel( new GridBagLayout() ); GridBagConstraints con = new GridBagConstraints(); con.fill = GridBagConstraints.HORIZONTAL; con.weightx = 1; con.anchor = GridBagConstraints.NORTHWEST; // Setup States Panels JPanel statesP = new JPanel( new GridBagLayout() ); border1 = BorderFactory.createEmptyBorder (4, 4, 2, 4); statesP.setBorder( BorderFactory.createCompoundBorder(border1, border2) ); JPanel statesP_in = new JPanel(new GridBagLayout() ); row = 0; col = 0; Enumeration enum = parent.stateDefs.elements(); while ( enum.hasMoreElements() ) { RecDef def = ( RecDef ) enum.nextElement(); if ( def.stateVector.size() > 0 ) { con.gridx = col; con.gridy = row; btn = new MyButton( def.description, "Press for " + def.description + " histogram", this ); statesP_in.add( btn, con); btn.setIcon( new ColoredRect( def.color ) ); btn.setHorizontalAlignment( btn.LEFT ); con.gridx = col + 1; def.checkbox = new JCheckBox( "", true ); statesP_in.add( def.checkbox, con ); def.checkbox.addItemListener( this ); def.checkbox.setToolTipText( "Enable or disable " + def.description ); if ( (col / 2) == numCols ) { col = 0; row ++; } else col += 2; } } con.gridx = 0; con.gridy = 0; con.fill = GridBagConstraints.NONE; con.weightx = 0; statesP.add( statesP_in, con ); // State Buttons Controls JPanel states_cntl = new JPanel( new GridLayout(2, 1) ); states_cntl.add( new MyButton( "All States On", "Enable all states", this) ); states_cntl.add( new MyButton( "All States Off", "Disable all states", this) ); con.gridx = 1; statesP.add( states_cntl, con ); con.gridx = 0; con.gridy = 0; mainPanel.add( statesP, con ); // Setup Arrows Panels if ( parent.arrowDefs.size() > 0 ) { row = 0; col = 0; JPanel arrowsP = new JPanel( new GridBagLayout() ); border1 = BorderFactory.createEmptyBorder (2, 4, 4, 4); arrowsP.setBorder( BorderFactory.createCompoundBorder( border1, border2 ) ); JPanel arrowsP_in = new JPanel( new GridBagLayout() ); enum = parent.arrowDefs.elements(); while ( enum.hasMoreElements() ) { RecDef def = ( RecDef ) enum.nextElement(); if ( def.stateVector.size() > 0 ) { con.gridx = col; con.gridy = row; btn = new MyButton( def.description, "Press for " + def.description + " histogram", this ); arrowsP_in.add( btn, con ); btn.setIcon( new ColoredRect( def.color ) ); btn.setHorizontalAlignment( btn.LEFT ); con.gridx = col + 1; def.checkbox = new JCheckBox( "", true ); arrowsP_in.add( def.checkbox, con ); def.checkbox.addItemListener( this ); def.checkbox.setToolTipText( "Enable or disable " + def.description ); if ( (col / 2) == numCols ) { col = 0; row ++; } else col += 2; } // Endof if ( def.stateVector.size() > 0 ) } con.gridx = 0; con.gridy = 0; con.fill = GridBagConstraints.NONE; con.weightx = 0; arrowsP.add( arrowsP_in, con ); // Arrow Buttons Controls JPanel arrows_cntl = new JPanel( new GridLayout(2, 1) ); arrows_cntl.add( new MyButton( "All Arrows On", "Enable all arrows", this) ); arrows_cntl.add( new MyButton( "All Arrows Off", "Disable all arrows", this) ); con.gridx = 1; arrowsP.add( arrows_cntl, con ); con.gridy = 2; con.gridx = 0; mainPanel.add( arrowsP, con ); } // Endof if ( parent.arrowDefs.size() > 0 ) //Add mainPanel to JScrollPane JScrollPane sP = new JScrollPane (mainPanel); sP.setPreferredSize (new Dimension (100, 100)); sP.setMinimumSize (new Dimension (100, 100)); add (sP); }
private void setHotKey() { addbt.setMnemonic('N'); deletebt.setMnemonic('D'); refreshbt.setMnemonic('R'); }
private void setHotKey() { approvebt.setMnemonic('A'); disappbt.setMnemonic('D'); refreshbt.setMnemonic('R'); }