Java Code Examples for javax.swing.JButton#getText()

The following examples show how to use javax.swing.JButton#getText() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JDayChooser.java    From MeteoInfo with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * JDayChooser is the ActionListener for all day buttons.
 * 
 * @param e
 *            the ActionEvent
 */
public void actionPerformed(ActionEvent e) {
	JButton button = (JButton) e.getSource();
	String buttonText = button.getText();
	int day = new Integer(buttonText).intValue();
	setDay(day);
}
 
Example 2
Source File: GridDesigner.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/**
 * Initializes undo/redo toolbar button.
 * 
 * @param button button to initialize.
 * @return initialized button.
 */
private JButton initUndoRedoButton(JButton button) {
    String text = (String)button.getAction().getValue(Action.NAME);
    Mnemonics.setLocalizedText(button, text);
    text = button.getText();
    button.setText(null);
    button.setToolTipText(text);
    button.setFocusPainted(false);
    return button;
}
 
Example 3
Source File: DomGui.java    From DominionSim with MIT License 5 votes vote down vote up
private DomPlayer getSelectedPlayer(JButton theSelector) {
	String theName = theSelector.getText();
	if (theName==null || theName.equals(""))
		return null;
       for (DomPlayer player : myEngine.getBotArray()) {
           if (player.toString().equals(theName))
               return player;
	}
	return null;
}
 
Example 4
Source File: AddFrame.java    From JavaMainRepo with Apache License 2.0 5 votes vote down vote up
public void setAquaticButtonActionListener(ActionListener a) {

		for (JButton b : typesOfAnimalsButtons) {
			if (b.getText() == Species.Aquatics) {
				b.addActionListener(a);
			}
		}
	}
 
Example 5
Source File: AddFrame.java    From JavaMainRepo with Apache License 2.0 5 votes vote down vote up
public void setBirdButtonActionListener(ActionListener a) {

		for (JButton b : typesOfAnimalsButtons) {
			if (b.getText() == Species.Birds) {
				b.addActionListener(a);
			}
		}
	}
 
Example 6
Source File: AddFrame.java    From JavaMainRepo with Apache License 2.0 5 votes vote down vote up
public void setInsectButtonActionListener(ActionListener a) {

		for (JButton b : typesOfAnimalsButtons) {
			if (b.getText() == Species.Insects) {
				b.addActionListener(a);
			}
		}
	}
 
Example 7
Source File: AddFrame.java    From JavaMainRepo with Apache License 2.0 5 votes vote down vote up
public void setMammalButtonActionListener(ActionListener a) {

		for (JButton b : typesOfAnimalsButtons) {
			if (b.getText() == Species.Mammals) {
				b.addActionListener(a);
			}
		}
	}
 
Example 8
Source File: AddFrame.java    From JavaMainRepo with Apache License 2.0 5 votes vote down vote up
public void setReptileButtonActionListener(ActionListener a) {

		for (JButton b : typesOfAnimalsButtons) {
			if (b.getText() == Species.Reptiles) {
				b.addActionListener(a);
			}
		}
	}
 
Example 9
Source File: AddFrame.java    From JavaMainRepo with Apache License 2.0 5 votes vote down vote up
public void setCaretakerButtonActionListener(ActionListener a) {

		for (JButton b : typesOfEmployeesButtons) {
			if (b.getText() == EmployeesType.Caretakers) {
				b.addActionListener(a);
			}
		}
	}
 
Example 10
Source File: ClockController.java    From JavaMainRepo with Apache License 2.0 5 votes vote down vote up
@Override
public void actionPerformed(ActionEvent e) {
	JButton buttonPressed = (JButton) e.getSource();
	if (lastButtonPressed == buttonPressed) {
		buttonPressedText = buttonPressed.getText();
	}
	lastButtonPressed = buttonPressed;
}
 
Example 11
Source File: CalculadoraTela.java    From dctb-utfpr-2018-1 with Apache License 2.0 4 votes vote down vote up
public void operarComBotaoClicado(java.awt.event.ActionEvent evt) {
    // Descobre o botão que foi clicado e devolve o caractere, nele, na variável texto
    JButton botao = (JButton) evt.getSource(); // Retorna o botão clicado
    String caractereDigitado = botao.getText(); // Retorna o texto do botão que foi clicado
    this.operarConformeEstado(caractereDigitado); // Oferece o texto do botão para calculadora executar a operação
}
 
Example 12
Source File: UnitTab.java    From netbeans with Apache License 2.0 4 votes vote down vote up
static String textForKey (String key) {
    JButton jb = new JButton ();
    Mnemonics.setLocalizedText (jb, NbBundle.getMessage (UnitTab.class, key));
    return jb.getText ();
}
 
Example 13
Source File: MainGui.java    From OpenID-Attacker with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void actionPerformed(ActionEvent e) {
    JButton pressedButton = (JButton) e.getSource();
    //System.out.println("pressed button: " + pressedButton.getText());
    
    if (pressedButton == lastPressedButton) {
        // do nothing
        return;
    }        
    
    // remove selection from LAST pressed button
    lastPressedButton.setFont(defaultFont);
    lastPressedButton = pressedButton;
    
    // add selection to pressed button
    pressedButton.setFont(boldUnderline);
    
    JXTaskPane taskPaneOfPressedButton = (JXTaskPane) SwingUtilities.getAncestorOfClass(JXTaskPane.class, pressedButton);
    
    if (taskPaneOfPressedButton.getTitle().equals("Attacker IdP")) {

        switch (pressedButton.getText()) {
            case "Server Configuration":
                splitPane.setRightComponent(attackerIdpServerConfigurationGui);
                
                break;
            case "HTML Discovery":
                splitPane.setRightComponent(attackerIdpHtmlConfigurationGui);
                break;
            case "XRDS Discovery":
                splitPane.setRightComponent(attackerIdpXrdsConfigurationGui);
                break;
            case "Valid Data":
                splitPane.setRightComponent(attackerIdpValidDataGui);
                break;
            case "Attack Data":
                splitPane.setRightComponent(attackerIdpAttackDataGui);
                break;
            case "Attack Overview":
                splitPane.setRightComponent(attackerIdpAttackOverviewGui);
                break;
        }
    } else {
        switch (pressedButton.getText()) {
            case "Server Configuration":
                splitPane.setRightComponent(analyzerIdpServerConfigurationGui);
                
                break;
            case "HTML Discovery":
                splitPane.setRightComponent(analyzerIdpHtmlConfigurationGui);
                break;
            case "XRDS Discovery":
                splitPane.setRightComponent(analyzerIdpXrdsConfigurationGui);
                break;
            case "Valid Data":
                splitPane.setRightComponent(analyzerIdpValidDataGui);
                break;
            case "Attack Data":
                splitPane.setRightComponent(analyzerIdpAttackDataGui);
                break;
            case "Parameter Overview":
                splitPane.setRightComponent(analyzerIdpAttackOverviewGui);
                break;
            case "Automated Analysis":
                splitPane.setRightComponent(evaluationGui);
                break;
            case "Reports":
                splitPane.setRightComponent(reportGui);
                break;
            case "Log":
                splitPane.setRightComponent(logGui);
                break;
        }
    }
}