public void actionPerformed(ActionEvent e) { JComboBox box = (JComboBox) e.getSource(); LogLevel level = (LogLevel) box.getSelectedItem(); setLeastSevereDisplayedLogLevel(level); } });
public class Calc extends JFrame implements ActionListener { private Button button1; public Calc() { super(); this.setSize(100, 100); this.setVisible(true); this.button1 = new JButton("1"); this.button1.addActionListener(this); this.add(button1); } public static void main(String[] args) { Calc calc = new Calc(); calc.setVisible(true); } public void actionPerformed(ActionEvent e) { if(e.getSource() == button1) } }
JButton yesButton = new JButton("YES"); JButton noButton = new JButton("NO"); yesButton.setPreferredSize(new Dimension(70, 30)); noButton.setPreferredSize(new Dimension(70, 30)); }); configLogLevelCombobox.addActionListener(arg0 -> { String level = ((JComboBox) arg0.getSource()).getSelectedItem().toString(); setLogLevel(level); }); configSelectLangComboBox.addActionListener(arg0 -> { String level = ((JComboBox) arg0.getSource()).getSelectedItem().toString(); rb = Utils.getResourceBundle(level); changeLocale(); Utils.setConfigBoolean("clipboard.autorip", configClipboardAutorip.isSelected()); ClipboardUtils.setClipboardAutoRip(configClipboardAutorip.isSelected()); trayMenuAutorip.setState(configClipboardAutorip.isSelected()); Utils.configureLogger(); });
@FXML private void handleButtonAction(ActionEvent event) { System.out.println("You clicked me!"); label.setText("Hello World!"); //Here I want to swap the screen! Stage stageTheEventSourceNodeBelongs = (Stage) ((Node)event.getSource()).getScene().getWindow(); // OR Stage stageTheLabelBelongs = (Stage) label.getScene().getWindow(); // these two of them return the same stage // Swap screen stage.setScene(new Scene(new Pane())); }
public class Dropdown implements ActionListener { public String selected; @Override public void actionPerformed(ActionEvent e) { JComboBox cb = (JComboBox) e.getSource(); System.out.println(cb.getSelectedItem()); } public Dropdown(String selected) { this.selected = selected; } }
JButton okButton = new JButton("OK"); okButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { JComboBox jComboBox1 = (JComboBox) e.getSource(); Item item = (Item) jComboBox1.getSelectedItem(); String code = (String) item.getValue(); System.out.println(code); } });
@Override public void actionPerformed(ActionEvent actionEvent) { final JCheckBox source = (JCheckBox) actionEvent.getSource(); final Resolution resolution = ((ResolutionButtonModel) source.getModel()).getResolution(); controller.setExportResolution(resolution, source.isSelected()); } };
public void actionPerformed(ActionEvent e) { Port port = getPort(); if (e.getSource() == labelField) { if (labelField.getText().equals(port.getDisplayLabel())) return; nodeAttributesDialog.setPortLabel(portName, labelField.getText()); } else if (e.getSource() == descriptionField) { nodeAttributesDialog.setPortDescription(portName, descriptionField.getText()); } else if (e.getSource() == widgetBox) { HumanizedObject newWidget = (HumanizedObject) widgetBox.getSelectedItem(); if (port.getWidget() == newWidget.getObject()) return; nodeAttributesDialog.setPortWidget(portName, (Port.Widget) newWidget.getObject()); } else if (e.getSource() == rangeBox) { HumanizedObject newRange = (HumanizedObject) rangeBox.getSelectedItem(); if (port.getRange() == newRange.getObject()) return; nodeAttributesDialog.setPortRange(portName, (Port.Range) newRange.getObject()); } else if (e.getSource() == valueField) { String newValue = valueField.getText(); if (port.getValue() != null && port.getValue().toString().equals(newValue)) return; } else if (e.getSource() == minimumValueCheck) { if (minimumValueCheck.isSelected() && port.getMinimumValue() != null) return; nodeAttributesDialog.setPortMinimumValue(portName, minimumValueCheck.isSelected() ? (double) 0f : null); } else if (e.getSource() == minimumValueField) { try { float v = Float.parseFloat(minimumValueField.getText()); } else if (e.getSource() == maximumValueCheck) { if (maximumValueCheck.isSelected() && port.getMaximumValue() != null) return; nodeAttributesDialog.setPortMaximumValue(portName, maximumValueCheck.isSelected() ? (double) 0f : null); } else if (e.getSource() == maximumValueField) {
this.setLayout(borderLayoutPreferences); final JButton buttonCheckIp = new JButton("Check your IP"); buttonCheckIp.addActionListener(new ActionCheckIP()); buttonCheckIp.setToolTipText( this.checkboxIsTamperingBase64.setToolTipText(tooltipIsTamperingBase64); this.checkboxIsTamperingBase64.setFocusable(false); JButton labelIsTamperingBase64 = new JButton("Encode SQL expression to Base64"); labelIsTamperingBase64.setToolTipText(tooltipIsTamperingBase64); labelIsTamperingBase64.addActionListener(actionEvent -> { this.checkboxIsTamperingBase64.setSelected(!this.checkboxIsTamperingBase64.isSelected()); this.actionListenerSave.actionPerformed(null); }); labelIsTamperingEqualToLike.setToolTipText(tooltipIsTamperingEqualToLike); labelIsTamperingEqualToLike.addActionListener(actionEvent -> { this.checkboxIsTamperingEqualToLike.setSelected(!this.checkboxIsTamperingEqualToLike.isSelected()); this.actionListenerSave.actionPerformed(null); }); if (actionEvent.getSource() != this.checkboxProcessCsrf) { this.checkboxProcessCsrf.setSelected(!this.checkboxProcessCsrf.isSelected()); if (actionEvent.getSource() != this.checkboxIsCheckingAllParam) { this.checkboxIsCheckingAllParam.setSelected(!this.checkboxIsCheckingAllParam.isSelected());
@Override public void actionPerformed(ActionEvent ae) { if (ae.getSource() == this.button1) { System.out .println(((MatrixButton) ae.getSource()).getRow() + "," + ((MatrixButton) ae.getSource()).getCol()); } else if (ae.getSource() == this.button2) { // TODO } else if (ae.getSource() == this.button3) { // TODO } }
String[] bookArray = {"a", "b", "c"}; JComboBox bookComboBox = new JComboBox(bookArray); bookComboBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { JComboBox cb = (JComboBox) e.getSource(); bookNameSelected = (String) cb.getSelectedItem(); System.out.println("book name selected:" + bookNameSelected); } }); bookComboBox.setSelectedIndex(0);
public void actionPerformed(ActionEvent e) { JComboBox box = (JComboBox) e.getSource(); String font = (String) box.getSelectedItem(); _table.setFont(new Font(font, Font.PLAIN, _fontSize)); _fontName = font; } }
@Override public void actionPerformed(ActionEvent actionEvent) { final JCheckBox source = (JCheckBox) actionEvent.getSource(); final Resolution resolution = ((ResolutionButtonModel) source.getModel()).getResolution(); if (source.isSelected()) { controller.addTargetResolution(resolution); } else { controller.removeTargetResolution(resolution); } } };
@Override public void actionPerformed(ActionEvent e) { if (e.getSource().equals(mBlackBorderEnable)) { mBlackBorderConfig.mBlackBorderEnabled = mBlackBorderEnable .isSelected(); toggleEnabled(mBlackBorderConfig.mBlackBorderEnabled); } mBlackBorderConfig.mBlackbordermCombo = (BlackBorderStandard) mBlackBordermCombo .getSelectedItem(); } };
public void actionPerformed(ActionEvent e) { JComboBox box = (JComboBox) e.getSource(); Node node = (Node) box.getSelectedItem(); System.out.println(node); if ("SELECT_ALL".equals(node.getName())) { nodes1 = new ArrayList<>(graph.getNodes()); } else { nodes1 = Collections.singletonList(node); } Preferences.userRoot().put("pathFrom", node.getName()); // update(graph, textArea, nodes1, nodes2, method); }
JButton button = new JButton("Button 1"); button.putClientProperty("ValueKey", "Actual value"); ActionListener listener = new ActionListener() { @Override public void actionPerformed(ActionEvent e) { JButton button = (JButton)e.getSource(); System.out.println(button.getClientProperty("ValueKey")); }; }