javax.swing.JButton.getName()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(5.9k)|赞(0)|评价(0)|浏览(127)

本文整理了Java中javax.swing.JButton.getName()方法的一些代码示例,展示了JButton.getName()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JButton.getName()方法的具体详情如下:
包路径:javax.swing.JButton
类名称:JButton
方法名:getName

JButton.getName介绍

暂无

代码示例

代码示例来源:origin: stackoverflow.com

JButton btnClear = new JButton("clear");
btnClear.addActionListener(this);
btnClear.setName("clear");

//..............
//..............

public void actionPerformed(ActionEvent e) {
  JButton o = (JButton)e.getSource();
  String name = o.getName();
  if (name == "clear")
  {
    euroMillText.setText("");
  }
  else if (name == "eumill")
  {
    getLottoNumbers();
  }
  //JOptionPane.showMessageDialog(null,name);      
}

代码示例来源:origin: stackoverflow.com

public void actionPerformed(ActionEvent e) {
      // get the button that was pressed
      JButton b = (JButton) e.getSource();

      // fire appropriate event
      if (b.getName().equals("Normal Setup")) {
        // set up for normal simulation
        fireSimulationEvent(SimulationEvent.NORMAL_SETUP_EVENT);
      } 
......

代码示例来源:origin: stackoverflow.com

for (int j = 0; j < MAX_COLUMNS; j++) {
   JButton button = new JButton("foo");
   rows[i].add(button, button.getName());
}

代码示例来源:origin: stackoverflow.com

for(JButton button : buttonList) {
  button.setText(languagePropertyManager.getProperty(button.getName()));
}

代码示例来源:origin: com.eas.platypus/platypus-js-forms

@Override
public String toString() {
  return String.format("%s [%s]", super.getName() != null ? super.getName() : "", getClass().getSimpleName());
}

代码示例来源:origin: stackoverflow.com

public void actionPerformed(ActionEvent e) {
 if(buttonA.contains(e.getSource())) {
     JButton btn = (JButton) e.getSource();
     display.setText(display.getText() + btn.getName());
 } else if() { // operations like +,- etc.,
 }

代码示例来源:origin: stackoverflow.com

b1.addActionListener(this);
b1.setName("OpenJDialog"); 
//this is to read in actionperformed method incase you have more than one button

// in action performed method call the dialogue class
public void actionPerformed(ActionEvent ae){

 JButton jb = (JButton)ae.getSource();
 String str = jb.getName();
 if(str.equals("OpenJDialog"){
   new OptionView(); 
   //I  am assuming u are configuring jdialog content in OptionView constructor
  }
}

代码示例来源:origin: stackoverflow.com

static class progHandler implements ActionListener{

  @Override
  public void actionPerformed(ActionEvent e){

    if(e.getSource().getClass().equals(JButton.class))
    {
      JButton buttonPressed = (JButton)e.getSource();
      if(buttonPressed.getName().equals("reserve A1"))//this is the symbol that it cannot find.
      {
        //do whatever you want
      }
    }
  }
}

代码示例来源:origin: stackoverflow.com

Random r = new Random();
int i = r.nextInt(5); // chooses 0, 1, .. 4
int j = r.nextInt(5);

JButton b = buttons[i][j];
b.setText(b.getName());

代码示例来源:origin: MegaMek/mekhq

@Override
  public void actionPerformed(java.awt.event.ActionEvent evt) {
    UUID id = UUID.fromString(evt.getActionCommand());
    int idx = Integer.parseInt(((JButton)evt.getSource()).getName());
    editUnit(id, idx, salvage);
  }
}

代码示例来源:origin: stackoverflow.com

@Override
public void actionPerformed(ActionEvent e) {
  // press the button
   System.out.println(e.getActionCommand()); 
   JButton btn=(JButton)e.getSource();
   System.out.println(btn.getName());  // use name or action command in if statment
}

代码示例来源:origin: com.eas.platypus/platypus-js-forms

@ScriptFunction(jsDoc = JS_NAME_DOC)
@Override
public String getName() {
  return super.getName();
}

代码示例来源:origin: Audiveris/audiveris

@Override
  public void actionPerformed (ActionEvent e)
  {
    String setName = ((JButton) e.getSource()).getName();
    ShapeSet set = ShapeSet.getShapeSet(setName);
    selectShapeSet(set);
  }
};

代码示例来源:origin: stackoverflow.com

private void JBsetseleccionadActionPerformed(java.awt.event.ActionEvent evt) {
  // TODO add your handling code here:
  Object boton = evt.getSource();
  JButton este = (JButton) boton;
  este.setName("button_name"); // set the name first

  seleccionado = este;
  System.out.println("SOURCE " + boton.toString());
  System.out.println("NAME " + este.getName());
}

代码示例来源:origin: stackoverflow.com

JButton randomButton = new JButton("I'm a label!");
 System.out.println(randomButton.getName()); // prints null
 System.out.println(randomButton.getText()); // prints the label

代码示例来源:origin: stackoverflow.com

public FlippingCoins() {
  final JPanel p = new JPanel();

  p.setLayout(new GridLayout(3, 3, 1, 1));

  for (int i = 0; i < 9; i++) {
    final JButton jbt = new JButton("H");
    jbt.setName("" + i);
    jbt.addActionListener(new ActionListener() {
      public void actionPerformed(final ActionEvent e) {
        jbt.setText("T");
        System.out.println(jbt.getName());
      }
    });
    p.add(jbt);
  }
  setContentPane(p);
}

代码示例来源:origin: freeplane/freeplane

protected void setButtonsVisible(JTable table, int row) {
  final ManageAddOnsPanel.AddOnTableModel model = (ManageAddOnsPanel.AddOnTableModel) table.getModel();
  final AddOnProperties addOn = model.getAddOnAt(row);
  for (JButton btn : buttons) {
    final boolean supportsOperation = addOn.supportsOperation(btn.getName());
    btn.setVisible(supportsOperation);
  }
}

代码示例来源:origin: stackoverflow.com

public void actionPerformed(ActionEvent e) {
   // press the button
   JButton button = (JButton)e.getSource();
   Syestem.out.println(button.getName()); // get the name
   System.out.println(button.getText()) // get the text content
   if(button.getText().equals("clearBtn"))
     // clear things for me
 }

代码示例来源:origin: stackoverflow.com

ActionListener actionListener = new ActionListener() {
  @Override
  public void actionPerformed(ActionEvent e) {
    if(e.getSource() instanceof JButton){
      JButton pressedButton = (JButton) e.getSource();
      String buttonsName = pressedButton.getName();
      String buttonsText = pressedButton.getText();
      // do something with those
    }
  }
};

JButton a = new JButton("A");
a.addActionListener(actionListener);
JButton b = new JButton("B");
b.addActionListener(actionListener);
....

代码示例来源:origin: org.apache.geronimo.daytrader.modules/wsappclient

/**
 * This method initializes jPanel1
 *
 * @return JPanel
 */
private JPanel getJPanel1() {
  if (jPanel1 == null) {
    jPanel1 = new JPanel();
    jPanel1.setLayout(null);
    jPanel1.add(getJButton1(), getJButton1().getName());
    jPanel1.setBounds(11, 142, 287, 38);
    jPanel1.setBackground(new java.awt.Color(245, 245, 245));
    jPanel1.setBorder(
      BorderFactory.createEtchedBorder(
        EtchedBorder.LOWERED));
  }
  return jPanel1;
}
/**

相关文章

微信公众号

最新文章

更多

JButton类方法