List of usage examples for javax.swing JButton setAction
@BeanProperty(visualUpdate = true, description = "the Action instance connected with this ActionEvent source") public void setAction(Action a)
Action
. From source file:Main.java
private void makeAddButton(String name, Color color) { JButton button = new JButton(name); button.setBackground(color);/*from www. j a va 2s . c o m*/ button.setAction(setColorAction); add(button); }
From source file:org.simbrain.plot.timeseries.TimeSeriesPlotPanel.java
/** * Add button for clearing graph data.//w w w. java 2s . co m */ public void addClearGraphDataButton() { JButton clearButton = new JButton("Clear"); clearButton.setAction(TimeSeriesPlotActions.getClearGraphAction(this)); buttonPanel.add(clearButton); }
From source file:org.simbrain.plot.timeseries.TimeSeriesPlotPanel.java
/** * Add buttons for adding and deleting sources. *//*w w w .j a v a 2 s . c o m*/ public void addAddDeleteButtons() { JButton deleteButton = new JButton("Delete"); deleteButton.setAction(TimeSeriesPlotActions.getRemoveSourceAction(this)); JButton addButton = new JButton("Add"); addButton.setAction(TimeSeriesPlotActions.getAddSourceAction(this)); buttonPanel.add(deleteButton); buttonPanel.add(addButton); }
From source file:org.simbrain.plot.rasterchart.RasterPlotPanel.java
/** * Add button for clearing graph data.//from www . ja va 2 s. c om */ public void addClearGraphDataButton() { JButton clearButton = new JButton("Clear"); clearButton.setAction(RasterPlotActions.getClearGraphAction(this)); buttonPanel.add(clearButton); }
From source file:org.simbrain.plot.rasterchart.RasterPlotPanel.java
/** * Add buttons for adding and deleting sources. *//*from w w w . j a va2s.co m*/ public void addAddDeleteButtons() { JButton deleteButton = new JButton("Delete"); deleteButton.setAction(RasterPlotActions.getRemoveSourceAction(this)); JButton addButton = new JButton("Add"); addButton.setAction(RasterPlotActions.getAddSourceAction(this)); buttonPanel.add(deleteButton); buttonPanel.add(addButton); }
From source file:org.simbrain.plot.timeseries.TimeSeriesPlotPanel.java
/** * Add button for showing preferences./*from ww w. j a v a2s.c o m*/ */ public void addPreferencesButton() { JButton prefsButton = new JButton("Prefs"); prefsButton.setHideActionText(true); prefsButton.setAction(TimeSeriesPlotActions.getPropertiesDialogAction(this)); buttonPanel.add(prefsButton); }
From source file:org.simbrain.plot.rasterchart.RasterPlotPanel.java
/** * Add button for showing preferences.// ww w .j a v a 2 s .c om */ public void addPreferencesButton() { JButton prefsButton = new JButton("Prefs"); prefsButton.setHideActionText(true); prefsButton.setAction(RasterPlotActions.getPropertiesDialogAction(this)); buttonPanel.add(prefsButton); }
From source file:au.org.ala.delta.intkey.ui.WebSearchDialog.java
/** * Create the dialog./* w w w . j av a2 s. c o m*/ */ public WebSearchDialog(Dialog owner) { super(owner); setName("WebSearchDialog"); ResourceMap resourceMap = Application.getInstance().getContext().getResourceMap(WebSearchDialog.class); resourceMap.injectFields(this); ActionMap actionMap = Application.getInstance().getContext().getActionMap(WebSearchDialog.class, this); setTitle(websearchTitle); setBounds(100, 100, 450, 250); getContentPane().setLayout(new BorderLayout()); contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5)); getContentPane().add(contentPanel, BorderLayout.CENTER); { lblSearchFor = new JLabel(searchForLabel); } txtSearch = new JTextField(); txtSearch.setColumns(10); final JLabel lblUsing = new JLabel(usingLabel); cmbSearchEngine = new JComboBox(); GroupLayout gl_contentPanel = new GroupLayout(contentPanel); gl_contentPanel.setHorizontalGroup(gl_contentPanel.createParallelGroup(Alignment.LEADING) .addGroup(gl_contentPanel.createSequentialGroup().addContainerGap() .addGroup(gl_contentPanel.createParallelGroup(Alignment.LEADING) .addComponent(lblSearchFor, GroupLayout.DEFAULT_SIZE, 404, Short.MAX_VALUE) .addComponent(cmbSearchEngine, 0, 404, Short.MAX_VALUE) .addComponent(txtSearch, GroupLayout.DEFAULT_SIZE, 404, Short.MAX_VALUE) .addComponent(lblUsing, GroupLayout.DEFAULT_SIZE, 404, Short.MAX_VALUE)) .addContainerGap())); gl_contentPanel .setVerticalGroup( gl_contentPanel.createParallelGroup(Alignment.LEADING) .addGroup(gl_contentPanel.createSequentialGroup().addContainerGap() .addComponent(lblSearchFor).addPreferredGap(ComponentPlacement.UNRELATED) .addComponent(txtSearch, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addGap(27).addComponent(lblUsing) .addPreferredGap(ComponentPlacement.UNRELATED) .addComponent(cmbSearchEngine, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addContainerGap(41, Short.MAX_VALUE))); contentPanel.setLayout(gl_contentPanel); { JPanel buttonPane = new JPanel(); buttonPane.setLayout(new FlowLayout(FlowLayout.CENTER)); getContentPane().add(buttonPane, BorderLayout.SOUTH); { JButton okButton = new JButton("[OK]"); okButton.setAction(actionMap.get("WebSearchDialog_search")); buttonPane.add(okButton); getRootPane().setDefaultButton(okButton); } { JButton cancelButton = new JButton("[Cancel]"); cancelButton.setAction(actionMap.get("WebSearchDialog_cancel")); buttonPane.add(cancelButton); } } LocalConfigFiles files = new LocalConfigFiles("intkey"); File f = files.getWebsearchIndexFile(); if (f.exists()) { loadSearchEngines(f, cmbSearchEngine); } cmbSearchEngine.requestFocus(); }
From source file:au.org.ala.delta.intkey.ui.CharacterValueInputDialog.java
public CharacterValueInputDialog(Frame owner, Character ch, ImageSettings imageSettings, boolean displayNumbering, boolean enableImagesButton, boolean imagesStartScaled, boolean advancedMode) { super(owner, true); ActionMap actionMap = Application.getInstance().getContext().getActionMap(CharacterValueInputDialog.class, this); // Have to pull these resource strings out manually as BSAF does not // play nicely with // class hierarchies. _fullCharacterTextCaption = UIUtils.getResourceString("CharacterValueInputDialog.fullCharacterTextCaption"); _notesCaption = UIUtils.getResourceString("CharacterValueInputDialog.notesCaption"); getContentPane().setLayout(new BorderLayout(0, 0)); setResizable(false);/*w w w . j av a 2s . c o m*/ setPreferredSize(new Dimension(600, 200)); _imagesStartScaled = imagesStartScaled; _ch = ch; _imageSettings = imageSettings; _buttonPanel = new JPanel(); _buttonPanel.setBorder(new EmptyBorder(0, 20, 10, 20)); getContentPane().add(_buttonPanel, BorderLayout.SOUTH); _buttonPanel.setLayout(new GridLayout(0, 4, 5, 5)); JButton _btnOk = new JButton(); _btnOk.setAction(actionMap.get("characterValueInputDialog_OK")); _btnImages = new JButton(); _btnImages.setAction(actionMap.get("characterValueInputDialog_Images")); if (ch.getImageCount() == 0 || !enableImagesButton) { _btnImages.setEnabled(false); } _btnFullText = new JButton(); _btnFullText.setAction(actionMap.get("characterValueInputDialog_FullText")); _btnFullText.setEnabled(true); _btnSearch = new JButton(); _btnSearch.setAction(actionMap.get("characterValueInputDialog_Search")); _btnSearch.setEnabled(true); _btnCancel = new JButton(); _btnCancel.setAction(actionMap.get("characterValueInputDialog_Cancel")); _btnNotes = new JButton(); _btnNotes.setAction(actionMap.get("characterValueInputDialog_Notes")); _btnNotes.setEnabled(true); _btnHelp = new JButton(); _btnHelp.setAction(actionMap.get("characterValueInputDialog_Help")); //Some of the buttons should not be displayed if not in advanced mode if (advancedMode) { _buttonPanel.add(_btnOk); _buttonPanel.add(_btnImages); _buttonPanel.add(_btnFullText); _buttonPanel.add(_btnSearch); _buttonPanel.add(_btnCancel); _buttonPanel.add(_btnNotes); _buttonPanel.add(_btnHelp); } else { _buttonPanel.add(_btnOk); _buttonPanel.add(_btnCancel); _buttonPanel.add(_btnNotes); _buttonPanel.add(_btnImages); } _pnlMain = new JPanel(); _pnlMain.setBorder(new EmptyBorder(10, 10, 10, 10)); getContentPane().add(_pnlMain, BorderLayout.CENTER); _pnlMain.setLayout(new BorderLayout(0, 0)); _lblCharacterDescription = new JLabel(); _lblCharacterDescription.setBorder(new EmptyBorder(0, 0, 5, 0)); _formatter = new CharacterFormatter(displayNumbering, CommentStrippingMode.RETAIN, AngleBracketHandlingMode.REMOVE_SURROUNDING_REPLACE_INNER, true, false); _lblCharacterDescription.setText(_formatter.formatCharacterDescription(_ch)); _pnlMain.add(_lblCharacterDescription, BorderLayout.NORTH); _btnImages.setEnabled(!_ch.getImages().isEmpty()); _btnNotes.setEnabled(StringUtils.isNotBlank(_ch.getNotes())); setLocationRelativeTo(owner); }
From source file:de.atomfrede.tools.evalutation.ui.ExceptionDialog.java
@SuppressWarnings("serial") @Override/*from w w w .j a v a2 s .c om*/ public ButtonPanel createButtonPanel() { ButtonPanel buttonPanel = new ButtonPanel(); JButton closeButton = new JButton(); JButton detailButton = new JButton(); detailButton.setMnemonic('D'); closeButton.setName(OK); buttonPanel.addButton(closeButton, ButtonPanel.AFFIRMATIVE_BUTTON); buttonPanel.addButton(detailButton, ButtonPanel.OTHER_BUTTON); closeButton.setAction(new AbstractAction("Close") { @Override public void actionPerformed(ActionEvent e) { setDialogResult(RESULT_AFFIRMED); setVisible(false); dispose(); } }); detailButton.setAction(new AbstractAction("Details >>") { @Override public void actionPerformed(ActionEvent e) { if (_detailsPanel.isVisible()) { _detailsPanel.setVisible(false); putValue(Action.NAME, "Details <<"); pack(); } else { _detailsPanel.setVisible(true); putValue(Action.NAME, "<< Details"); pack(); } } }); setDefaultCancelAction(closeButton.getAction()); setDefaultAction(closeButton.getAction()); getRootPane().setDefaultButton(closeButton); buttonPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); buttonPanel.setSizeConstraint(ButtonPanel.NO_LESS_THAN); return buttonPanel; }