List of usage examples for javax.swing AbstractAction AbstractAction
public AbstractAction()
From source file:de.tor.tribes.ui.views.DSWorkbenchSOSRequestAnalyzer.java
/** * Creates new form DSWorkbenchSOSRequestAnalyzer *///from www .j a v a 2 s. c o m DSWorkbenchSOSRequestAnalyzer() { initComponents(); centerPanel = new GenericTestPanel(true); jSOSPanel.add(centerPanel, BorderLayout.CENTER); centerPanel.setChildComponent(jSOSInputPanel); buildMenu(); jButton1.setIcon(new ImageIcon("./graphics/big/find.png")); capabilityInfoPanel1.addActionListener(DSWorkbenchSOSRequestAnalyzer.this); // KeyStroke copy = KeyStroke.getKeyStroke(KeyEvent.VK_C, ActionEvent.CTRL_MASK, false); KeyStroke bbCopy = KeyStroke.getKeyStroke(KeyEvent.VK_B, ActionEvent.CTRL_MASK, false); KeyStroke delete = KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0, false); //KeyStroke cut = KeyStroke.getKeyStroke(KeyEvent.VK_X, ActionEvent.CTRL_MASK, false); // jAttacksTable.registerKeyboardAction(DSWorkbenchSOSRequestAnalyzer.this, "Copy", copy, JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); jAttacksTable.registerKeyboardAction(DSWorkbenchSOSRequestAnalyzer.this, "BBCopy", bbCopy, JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); jAttacksTable.registerKeyboardAction(DSWorkbenchSOSRequestAnalyzer.this, "Delete", delete, JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); // jAttacksTable.registerKeyboardAction(DSWorkbenchSOSRequestAnalyzer.this, "Cut", cut, JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); jAttacksTable.getActionMap().put("find", new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { //ignore find } }); jAttacksTable.setModel(new DefenseToolModel()); jAttacksTable.setHighlighters( HighlighterFactory.createAlternateStriping(Constants.DS_ROW_A, Constants.DS_ROW_B)); jAttacksTable.getColumnExt("Tendenz").setCellRenderer(new TendencyTableCellRenderer()); jAttacksTable.getColumnExt("Status").setCellRenderer(new DefenseStatusTableCellRenderer()); //jAttacksTable.getColumnExt("Wall").setCellRenderer(new WallLevellCellRenderer()); jAttacksTable.getColumnExt("Verlustrate").setCellRenderer(new LossRatioTableCellRenderer()); jAttacksTable.setDefaultRenderer(Date.class, new DateCellRenderer()); jAttacksTable.setColumnControlVisible(false); jAttacksTable.setDefaultRenderer(Date.class, new DateCellRenderer()); jAttacksTable.getTableHeader().setDefaultRenderer(new DefaultTableHeaderRenderer()); jAttacksTable.requestFocus(); jSupportsTable.setModel(new SupportsModel()); jSupportsTable.setHighlighters( HighlighterFactory.createAlternateStriping(Constants.DS_ROW_A, Constants.DS_ROW_B)); jSupportsTable.getTableHeader().setDefaultRenderer(new DefaultTableHeaderRenderer()); jSupportsTable.setDefaultRenderer(Date.class, new ColoredDateCellRenderer()); jSupportsTable.setDefaultRenderer(Boolean.class, new CustomBooleanRenderer(CustomBooleanRenderer.LayoutStyle.SENT_NOTSENT)); new SupportCountdownThread().start(); new SupportColorUpdateThread().start(); jXInfoLabel.setLineWrap(true); // <editor-fold defaultstate="collapsed" desc=" Init HelpSystem "> if (!Constants.DEBUG) { GlobalOptions.getHelpBroker().enableHelpKey(getRootPane(), "pages.sos_analyzer", GlobalOptions.getHelpBroker().getHelpSet()); } // </editor-fold> }
From source file:de.mprengemann.intellij.plugin.androidicons.dialogs.AndroidBatchScaleImporter.java
private void initButtons(final Project project) { addButton.addActionListener(new ActionListener() { @Override//from w w w .j a va 2 s . c om public void actionPerformed(ActionEvent actionEvent) { FileChooser.chooseFiles(FileBrowserField.IMAGE_FILES_FOLDER_CHOOSER, project, getInitialFile(), fileChooserConsumer); } }); deleteButton.addActionListener(new AbstractAction() { @Override public void actionPerformed(ActionEvent actionEvent) { controller.removeImages(table.getSelectedRows()); } }); editButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { controller.editImages(project, module, table.getSelectedRows()); } }); }
From source file:org.nuclos.client.genericobject.statehistory.StateHistoryController.java
private static void setupEscapeKey(final MainFrameTab ifrm, final StateHistoryPanel pnlHistory) { // Escape key is to close the window: final Action actClose = new AbstractAction() { @Override/*w w w . j a v a 2s . c o m*/ public void actionPerformed(ActionEvent ev) { ifrm.dispose(); } }; final String KEY_CLOSE = "Close"; ifrm.getRootPane().getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT) .put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), KEY_CLOSE); ifrm.getRootPane().getActionMap().put(KEY_CLOSE, actClose); pnlHistory.getTable().getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), KEY_CLOSE); pnlHistory.getTable().getActionMap().put(KEY_CLOSE, actClose); }
From source file:org.executequery.gui.browser.TableDataTab.java
private JPanel createCanEditTableNotePanel() { final JPanel panel = new JPanel(new GridBagLayout()); canEditTableLabel = new UpdatableLabel(); JButton hideButton = new LinkButton(new AbstractAction() { public void actionPerformed(ActionEvent e) { panel.setVisible(false);//from w w w . j a v a 2 s. co m } }); hideButton.setText("Hide"); JButton alwaysHideButton = new LinkButton(new AbstractAction() { public void actionPerformed(ActionEvent e) { panel.setVisible(false); alwaysShowCanEditNotePanel = false; SystemProperties.setBooleanProperty(Constants.USER_PROPERTIES_KEY, "browser.always.show.table.editable.label", false); EventMediator.fireEvent( new DefaultUserPreferenceEvent(TableDataTab.this, null, UserPreferenceEvent.ALL)); } }); alwaysHideButton.setText("Always Hide"); GridBagConstraints gbc = new GridBagConstraints(); gbc.gridx++; gbc.weightx = 1.0; gbc.insets = new Insets(5, 5, 5, 5); gbc.anchor = GridBagConstraints.WEST; panel.add(canEditTableLabel, gbc); gbc.gridx++; gbc.weightx = 0; gbc.anchor = GridBagConstraints.EAST; panel.add(hideButton, gbc); gbc.gridx++; gbc.insets.left = 15; gbc.insets.right = 10; panel.add(alwaysHideButton, gbc); panel.setBorder(UIUtils.getDefaultLineBorder()); return panel; }
From source file:edu.ucla.stat.SOCR.chart.demo.PowerTransformHistogramChart.java
protected void createActionComponents(JToolBar toolBar) { super.createActionComponents(toolBar); JButton button;// ww w . jav a2 s .c o m /**************** wiki Tab ****************/ Action linkAction = new AbstractAction() { public void actionPerformed(ActionEvent e) { try { parentApplet.getAppletContext().showDocument(new java.net.URL( "http://wiki.stat.ucla.edu/socr/index.php/SOCR_EduMaterials_Activities_PowerTransformFamily_Graphs"), "SOCR: Power Transform Graphing Activity"); } catch (MalformedURLException Exc) { JOptionPane.showMessageDialog(null, Exc, "MalformedURL Error", JOptionPane.ERROR_MESSAGE); Exc.printStackTrace(); } } }; button = toolBar.add(linkAction); button.setText(" WIKI_Activity "); button.setToolTipText("Press this Button to go to SOCR_POWER_Activity wiki page"); }
From source file:aurelienribon.gdxsetupui.ui.panels.LibrarySelectionPanel.java
private void buildLibraryPanel(final String libraryName) { ActionListener nameChkAL = new ActionListener() { @Override// www . j a v a2 s. c o m public void actionPerformed(ActionEvent e) { if (((CompactCheckBox) e.getSource()).isSelected()) { if (!Ctx.cfgSetup.libraries.contains(libraryName)) Ctx.cfgSetup.libraries.add(libraryName); if (!Ctx.cfgUpdate.libraries.contains(libraryName)) Ctx.cfgUpdate.libraries.add(libraryName); } else { Ctx.cfgSetup.libraries.remove(libraryName); Ctx.cfgUpdate.libraries.remove(libraryName); } Ctx.fireCfgSetupChanged(); Ctx.fireCfgUpdateChanged(); } }; Action infoAction = new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { showInfo(libraryName); } }; Action browseAction = new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { browse(libraryName); } }; Action getStableAction = new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { getStable(libraryName); } }; Action getLatestAction = new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { getLatest(libraryName); } }; LibraryDef def = Ctx.libs.getDef(libraryName); CompactCheckBox nameChk = new CompactCheckBox(def.name + " "); JLabel html5Label = new JLabel(Res.getImage("gfx/ic_html5.png")); JButton infoBtn = new JButton(infoAction); JButton browseBtn = new JButton(browseAction); JButton getStableBtn = new JButton(getStableAction); JButton getLatestBtn = new JButton(getLatestAction); nameChk.addActionListener(nameChkAL); nameChk.setForeground(LIB_NOTFOUND_COLOR); html5Label.setToolTipText("Compatible with HTML backend"); infoBtn.setIcon(Res.getImage("gfx/ic_info.png")); browseBtn.setIcon(Res.getImage("gfx/ic_browse.png")); getStableBtn.setIcon(Res.getImage("gfx/ic_download_stable.png")); getLatestBtn.setIcon(Res.getImage("gfx/ic_download_nightlies.png")); infoBtn.setFocusable(false); browseBtn.setFocusable(false); getStableBtn.setFocusable(false); getLatestBtn.setFocusable(false); JToolBar toolBar = new JToolBar(); toolBar.setOpaque(false); toolBar.setFloatable(false); toolBar.add(Box.createHorizontalGlue()); toolBar.add(infoBtn); toolBar.add(browseBtn); if (def.stableUrl != null) toolBar.add(getStableBtn); else toolBar.add(Box.createHorizontalStrut(libgdxGetStableBtn.getPreferredSize().width)); if (def.latestUrl != null) toolBar.add(getLatestBtn); else toolBar.add(Box.createHorizontalStrut(libgdxGetNightliesBtn.getPreferredSize().width)); JPanel leftPanel = new JPanel(new BorderLayout()); leftPanel.setOpaque(false); leftPanel.add(nameChk, BorderLayout.CENTER); if (def.gwtModuleName != null) leftPanel.add(html5Label, BorderLayout.EAST); JPanel panel = new JPanel(new BorderLayout()); panel.setMaximumSize(new Dimension(Integer.MAX_VALUE, 25)); panel.setOpaque(false); panel.add(leftPanel, BorderLayout.WEST); panel.add(toolBar, BorderLayout.CENTER); librariesPanel.add(panel); Style.apply(librariesPanel, style); libsNamesCmps.put(libraryName, nameChk); }
From source file:org.geopublishing.atlasStyler.swing.PolygonSymbolEditGUI.java
/** * This method initializes jButton// w ww. j a v a2s.c om * * @return javax.swing.JButton */ private JButton getJButtonFillGraphic() { if (jButtonFillGraphic == null) { jButtonFillGraphic = new JButton(); boolean enabled = false; if (symbolizer.getFill() != null) { Graphic graphicFill = symbolizer.getFill().getGraphicFill(); enabled = (graphicFill != null); } jButtonFillGraphic.setAction(new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { if (symbolizer.getFill() == null) { symbolizer.setFill(StylingUtil.STYLE_BUILDER.createFill((Color) null, (Color) null, 1., StylingUtil.STYLE_BUILDER.createGraphic())); } JDialog editFillGraphicJDialog = new GraphicEditGUIinDialog(asv, SwingUtil.getParentWindow(PolygonSymbolEditGUI.this), symbolizer.getFill()); editFillGraphicJDialog.addPropertyChangeListener(new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { if (evt.getPropertyName().equals(AbstractStyleEditGUI.PROPERTY_UPDATED)) { PolygonSymbolEditGUI.this.firePropertyChange(AbstractStyleEditGUI.PROPERTY_UPDATED, null, null); // Update the Button Icon jButtonFillGraphic.setIcon(new ImageIcon(ASUtil.getSymbolizerImage(symbolizer, FeatureUtil.createFeatureType(Polygon.class)))); } } }); SwingUtil.setRelativeFramePosition(editFillGraphicJDialog, PolygonSymbolEditGUI.this, SwingUtil.BOUNDS_OUTER, SwingUtil.NORTHEAST); editFillGraphicJDialog.setVisible(true); } }); // Initialize correctly jLabelFillGraphic.setEnabled(enabled); jButtonFillGraphic.setEnabled(enabled); if (enabled) { jButtonFillGraphic.setIcon(new ImageIcon( ASUtil.getSymbolizerImage(symbolizer, FeatureUtil.createFeatureType(Polygon.class)))); } } return jButtonFillGraphic; }
From source file:net.sf.jabref.gui.fieldeditors.FileListEditor.java
public FileListEditor(JabRefFrame frame, BibDatabaseContext databaseContext, String fieldName, String content, EntryEditor entryEditor) {/*from w w w.ja v a 2s.c o m*/ this.frame = frame; this.databaseContext = databaseContext; this.fieldName = fieldName; this.entryEditor = entryEditor; label = new FieldNameLabel(fieldName); tableModel = new FileListTableModel(); setText(content); setModel(tableModel); JScrollPane sPane = new JScrollPane(this); setTableHeader(null); addMouseListener(new TableClickListener()); JButton add = new JButton(IconTheme.JabRefIcon.ADD_NOBOX.getSmallIcon()); add.setToolTipText(Localization.lang("New file link (INSERT)")); JButton remove = new JButton(IconTheme.JabRefIcon.REMOVE_NOBOX.getSmallIcon()); remove.setToolTipText(Localization.lang("Remove file link (DELETE)")); JButton up = new JButton(IconTheme.JabRefIcon.UP.getSmallIcon()); JButton down = new JButton(IconTheme.JabRefIcon.DOWN.getSmallIcon()); auto = new JButton(Localization.lang("Get fulltext")); JButton download = new JButton(Localization.lang("Download from URL")); add.setMargin(new Insets(0, 0, 0, 0)); remove.setMargin(new Insets(0, 0, 0, 0)); up.setMargin(new Insets(0, 0, 0, 0)); down.setMargin(new Insets(0, 0, 0, 0)); add.addActionListener(e -> addEntry()); remove.addActionListener(e -> removeEntries()); up.addActionListener(e -> moveEntry(-1)); down.addActionListener(e -> moveEntry(1)); auto.addActionListener(e -> autoSetLinks()); download.addActionListener(e -> downloadFile()); FormBuilder builder = FormBuilder.create() .layout(new FormLayout("fill:pref,1dlu,fill:pref,1dlu,fill:pref", "fill:pref,fill:pref")); builder.add(up).xy(1, 1); builder.add(add).xy(3, 1); builder.add(auto).xy(5, 1); builder.add(down).xy(1, 2); builder.add(remove).xy(3, 2); builder.add(download).xy(5, 2); panel = new JPanel(); panel.setLayout(new BorderLayout()); panel.add(sPane, BorderLayout.CENTER); panel.add(builder.getPanel(), BorderLayout.EAST); TransferHandler transferHandler = new FileListEditorTransferHandler(frame, entryEditor, null); setTransferHandler(transferHandler); panel.setTransferHandler(transferHandler); // Add an input/action pair for deleting entries: getInputMap().put(KeyStroke.getKeyStroke("DELETE"), "delete"); getActionMap().put("delete", new AbstractAction() { @Override public void actionPerformed(ActionEvent actionEvent) { int row = getSelectedRow(); removeEntries(); row = Math.min(row, getRowCount() - 1); if (row >= 0) { setRowSelectionInterval(row, row); } } }); // Add an input/action pair for inserting an entry: getInputMap().put(KeyStroke.getKeyStroke("INSERT"), "insert"); getActionMap().put("insert", new AbstractAction() { @Override public void actionPerformed(ActionEvent actionEvent) { addEntry(); } }); // Add input/action pair for moving an entry up: getInputMap().put(Globals.getKeyPrefs().getKey(KeyBinding.FILE_LIST_EDITOR_MOVE_ENTRY_UP), "move up"); getActionMap().put("move up", new AbstractAction() { @Override public void actionPerformed(ActionEvent actionEvent) { moveEntry(-1); } }); // Add input/action pair for moving an entry down: getInputMap().put(Globals.getKeyPrefs().getKey(KeyBinding.FILE_LIST_EDITOR_MOVE_ENTRY_DOWN), "move down"); getActionMap().put("move down", new AbstractAction() { @Override public void actionPerformed(ActionEvent actionEvent) { moveEntry(1); } }); JMenuItem openLink = new JMenuItem(Localization.lang("Open")); menu.add(openLink); openLink.addActionListener(e -> openSelectedFile()); JMenuItem openFolder = new JMenuItem(Localization.lang("Open folder")); menu.add(openFolder); openFolder.addActionListener(e -> { int row = getSelectedRow(); if (row >= 0) { FileListEntry entry = tableModel.getEntry(row); try { String path = ""; // absolute path if (Paths.get(entry.link).isAbsolute()) { path = Paths.get(entry.link).toString(); } else { // relative to file folder for (String folder : databaseContext.getFileDirectory()) { Path file = Paths.get(folder, entry.link); if (Files.exists(file)) { path = file.toString(); break; } } } if (!path.isEmpty()) { JabRefDesktop.openFolderAndSelectFile(path); } else { JOptionPane.showMessageDialog(frame, Localization.lang("File not found"), Localization.lang("Error"), JOptionPane.ERROR_MESSAGE); } } catch (IOException ex) { LOGGER.debug("Cannot open folder", ex); } } }); JMenuItem rename = new JMenuItem(Localization.lang("Move/Rename file")); menu.add(rename); rename.addActionListener(new MoveFileAction(frame, entryEditor, this, false)); JMenuItem moveToFileDir = new JMenuItem(Localization.lang("Move file to file directory")); menu.add(moveToFileDir); moveToFileDir.addActionListener(new MoveFileAction(frame, entryEditor, this, true)); JMenuItem deleteFile = new JMenuItem(Localization.lang("Delete local file")); menu.add(deleteFile); deleteFile.addActionListener(e -> { int row = getSelectedRow(); // no selection if (row != -1) { FileListEntry entry = tableModel.getEntry(row); // null if file does not exist Optional<File> file = FileUtil.expandFilename(databaseContext, entry.link); // transactional delete and unlink try { if (file.isPresent()) { Files.delete(file.get().toPath()); } removeEntries(); } catch (IOException ex) { JOptionPane.showMessageDialog(frame, Localization.lang("File permission error"), Localization.lang("Cannot delete file"), JOptionPane.ERROR_MESSAGE); LOGGER.warn("File permission error while deleting: " + entry.link, ex); } } }); adjustColumnWidth(); }
From source file:org.nuxeo.launcher.sync.NuxeoSyncFrame.java
protected Action createSyncAction() { return new AbstractAction() { private static final long serialVersionUID = 1L; @Override/*from w w w. j a va 2 s . c om*/ public void actionPerformed(ActionEvent event) { String serverip = syncServerIpTextField.getText(); String port = syncPortTextField.getText(); String login = syncLoginTextField.getText(); char[] password = syncPasswordField.getPassword(); HttpAutomationClient client = new HttpAutomationClient( "http://localhost:8080/nuxeo/site/automation"); // anonymous locally Session session; try { session = client.getSession(); OperationRequest request; request = session.newRequest("Synchronization.ClientSync"); request = request.set("host", serverip); request = request.set("port", port); request = request.set("username", login); request = request.set("password", new String(password)); request.execute(); getErrorMessageLabel().setText(""); } catch (Exception e) { errorMessageLabel.setText("<html>" + " an error occurred while synchronizing" + "<br> [" + e.getMessage() + "]" + "</html>"); syncPanel.updateUI(); } finally { client.shutdown(); } } }; }
From source file:de.codesourcery.eve.skills.ui.components.impl.BlueprintBrowserComponent.java
@Override protected JPanel createPanel() { popupMenuBuilder.addItem("Create production plan...", new AbstractAction() { @Override//w w w.j a v a 2 s .c om public boolean isEnabled() { return blueprintChooser.getCurrentlySelectedBlueprint() != null; } @Override public void actionPerformed(ActionEvent e) { final Blueprint blueprint = blueprintChooser.getCurrentlySelectedBlueprint(); if (blueprint != null) { doubleClicked(blueprint); } } }); // add text fields final JPanel textFields = new JPanel(); textFields.setLayout(new GridBagLayout()); selectedME.setColumns(5); selectedPE.setColumns(5); quantity.setColumns(6); selectedME.setHorizontalAlignment(JTextField.RIGHT); selectedPE.setHorizontalAlignment(JTextField.RIGHT); quantity.setHorizontalAlignment(JTextField.RIGHT); selectedME.addActionListener(this); selectedPE.addActionListener(this); quantity.addActionListener(this); textFields.add(new JLabel("ME"), constraints(0, 0).resizeBoth().end()); textFields.add(selectedME, constraints(1, 0).weightX(0.1).anchorWest().end()); textFields.add(new JLabel("PE"), constraints(0, 1).resizeBoth().end()); textFields.add(selectedPE, constraints(1, 1).weightX(0.1).anchorWest().end()); textFields.add(new JLabel("Quantity"), constraints(0, 2).resizeBoth().end()); textFields.add(quantity, constraints(1, 2).weightX(0.1).anchorWest().end()); // add combobox with cost calculators // add POS / NPC station buttons + label JPanel buttonPanel = new JPanel(); final ButtonGroup group = new ButtonGroup(); group.add(posButton); group.add(npcStationButton); posButton.addActionListener(this); npcStationButton.addActionListener(this); buttonPanel.add(posButton); buttonPanel.add(npcStationButton); textFields.add(new JLabel("Location"), constraints(0, 3).noResizing().end()); textFields.add(buttonPanel, constraints(1, 3).useRemainingWidth().end()); // add text area textArea.setEditable(false); textArea.setLineWrap(true); textArea.setWrapStyleWord(true); setMonospacedFont(textArea); final JPanel rightPanel = new JPanel(); rightPanel.setLayout(new GridBagLayout()); rightPanel.add(textFields, constraints(0, 0).noResizing().end()); rightPanel.add(new JScrollPane(textArea), constraints(0, 1).useRemainingSpace().end()); final ImprovedSplitPane splitPane = new ImprovedSplitPane(JSplitPane.HORIZONTAL_SPLIT, this.blueprintChooser.createPanel(), rightPanel); splitPane.setDividerLocation(0.4); final JPanel panel = new JPanel(); panel.setLayout(new GridBagLayout()); panel.add(splitPane, constraints(0, 0).resizeBoth().end()); return panel; }