List of usage examples for javax.swing AbstractAction AbstractAction
public AbstractAction()
From source file:org.kse.gui.dialogs.DCheckUpdate.java
private void initComponents() { jlCheckUpdate = new JLabel(res.getString("DCheckUpdate.jlCheckUpdate.text")); ImageIcon icon = new ImageIcon(getClass().getResource(res.getString("DCheckUpdate.jlCheckUpdate.image"))); jlCheckUpdate.setIcon(icon);// w w w.j a va 2 s .c o m jlCheckUpdate.setHorizontalTextPosition(SwingConstants.LEADING); jlCheckUpdate.setIconTextGap(15); jpCheckUpdate = new JPanel(new FlowLayout(FlowLayout.CENTER)); jpCheckUpdate.add(jlCheckUpdate); jpCheckUpdate.setBorder(new EmptyBorder(5, 5, 5, 5)); jpbCheckUpdate = new JProgressBar(); jpbCheckUpdate.setIndeterminate(true); jpbCheckUpdate.setString("DCheckUpdate.jlCheckUpdate.text"); jpProgress = new JPanel(new FlowLayout(FlowLayout.CENTER)); jpProgress.add(jpbCheckUpdate); jpProgress.setBorder(new EmptyBorder(5, 5, 5, 5)); jbCancel = new JButton(res.getString("DCheckUpdate.jbCancel.text")); jbCancel.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { cancelPressed(); } }); jbCancel.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), CANCEL_KEY); jbCancel.getActionMap().put(CANCEL_KEY, new AbstractAction() { private static final long serialVersionUID = 1L; @Override public void actionPerformed(ActionEvent evt) { cancelPressed(); } }); jpCancel = PlatformUtil.createDialogButtonPanel(jbCancel, false); getContentPane().add(jpCheckUpdate, BorderLayout.NORTH); getContentPane().add(jpProgress, BorderLayout.CENTER); getContentPane().add(jpCancel, BorderLayout.SOUTH); addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent evt) { if ((checker != null) && (checker.isAlive())) { checker.interrupt(); } closeDialog(); } }); setTitle(res.getString("DCheckUpdate.Title")); setResizable(false); pack(); }
From source file:edu.ucla.stat.SOCR.chart.demo.PowerTransformationFamilyChart.java
protected void createActionComponents(JToolBar toolBar) { super.createActionComponents(toolBar); JButton button;/* w w w . j a v a 2 s .c o m*/ /**************** wiki Tab ****************/ Action linkAction = new AbstractAction() { public void actionPerformed(ActionEvent e) { try { //popInfo("SOCRChart: About", new java.net.URL("http://wiki.stat.ucla.edu/socr/index.php/SOCR_EduMaterials_Activities_PowerTransformFamily_Graphs"), "SOCR: Power Transform Graphing Activity"); 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:com.romraider.logger.ecu.ui.handler.graph.GraphUpdateHandler.java
public GraphUpdateHandler(final JPanel panel) { this.graphPanel = new JPanel(new SpringLayout()); final JCheckBox combinedCheckbox = new JCheckBox("Combine Graphs", combinedChart); combinedCheckbox.addActionListener(new CombinedActionListener(combinedCheckbox)); JToggleButton playPauseButton = new JToggleButton("Pause Graphs"); playPauseButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { paused = !paused;/*from www.j a va2 s . co m*/ if (paused) { pauseStartTime = System.currentTimeMillis(); } else { startTime = startTime + (System.currentTimeMillis() - pauseStartTime); } } }); panel.getInputMap(WHEN_IN_FOCUSED_WINDOW).put(getKeyStroke("F12"), "toggleCombineGraphs"); panel.getActionMap().put("toggleCombineGraphs", new AbstractAction() { private static final long serialVersionUID = 1540427179539775534L; public void actionPerformed(ActionEvent e) { combinedCheckbox.doClick(); } }); JPanel controlPanel = new JPanel(); controlPanel.add(combinedCheckbox); controlPanel.add(playPauseButton); panel.add(controlPanel, NORTH); panel.add(this.graphPanel, CENTER); }
From source file:net.sf.keystore_explorer.gui.dialogs.DCheckUpdate.java
private void initComponents() { jlCheckUpdate = new JLabel(res.getString("DCheckUpdate.jlCheckUpdate.text")); ImageIcon icon = new ImageIcon(getClass().getResource(res.getString("DCheckUpdate.jlCheckUpdate.image"))); jlCheckUpdate.setIcon(icon);//from w w w .j a va2s. c o m jlCheckUpdate.setHorizontalTextPosition(SwingConstants.LEADING); jlCheckUpdate.setIconTextGap(15); jpCheckUpdate = new JPanel(new FlowLayout(FlowLayout.CENTER)); jpCheckUpdate.add(jlCheckUpdate); jpCheckUpdate.setBorder(new EmptyBorder(5, 5, 5, 5)); jpbCheckUpdate = new JProgressBar(); jpbCheckUpdate.setIndeterminate(true); jpbCheckUpdate.setString("DCheckUpdate.jlCheckUpdate.text"); jpProgress = new JPanel(new FlowLayout(FlowLayout.CENTER)); jpProgress.add(jpbCheckUpdate); jpProgress.setBorder(new EmptyBorder(5, 5, 5, 5)); jbCancel = new JButton(res.getString("DCheckUpdate.jbCancel.text")); jbCancel.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { cancelPressed(); } }); jbCancel.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), CANCEL_KEY); jbCancel.getActionMap().put(CANCEL_KEY, new AbstractAction() { @Override public void actionPerformed(ActionEvent evt) { cancelPressed(); } }); jpCancel = PlatformUtil.createDialogButtonPanel(jbCancel, false); getContentPane().add(jpCheckUpdate, BorderLayout.NORTH); getContentPane().add(jpProgress, BorderLayout.CENTER); getContentPane().add(jpCancel, BorderLayout.SOUTH); addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent evt) { if ((checker != null) && (checker.isAlive())) { checker.interrupt(); } closeDialog(); } }); setTitle(res.getString("DCheckUpdate.Title")); setResizable(false); pack(); }
From source file:net.sf.jabref.openoffice.CitationManager.java
public CitationManager(final JabRefFrame frame, OOBibBase ooBase) throws NoSuchElementException, WrappedTargetException, UnknownPropertyException { diag = new JDialog(frame, Localization.lang("Manage citations"), true); this.ooBase = ooBase; list = new BasicEventList<>(); XNameAccess nameAccess = ooBase.getReferenceMarks(); java.util.List<String> names = ooBase.getJabRefReferenceMarks(nameAccess); for (String name : names) { list.add(new CitEntry(name, "<html>..." + ooBase.getCitationContext(nameAccess, name, 30, 30, true) + "...</html>", ooBase.getCustomProperty(name))); }/* w ww. j av a 2 s .c o m*/ tableModel = new DefaultEventTableModel<>(list, new CitEntryFormat()); table = new JTable(tableModel); diag.add(new JScrollPane(table), BorderLayout.CENTER); ButtonBarBuilder bb = new ButtonBarBuilder(); bb.addGlue(); JButton ok = new JButton(Localization.lang("OK")); bb.addButton(ok); JButton cancel = new JButton(Localization.lang("Cancel")); bb.addButton(cancel); bb.addGlue(); bb.getPanel().setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); diag.add(bb.getPanel(), BorderLayout.SOUTH); diag.pack(); diag.setSize(700, 400); ok.addActionListener(e -> { try { storeSettings(); } catch (UnknownPropertyException | NotRemoveableException | PropertyExistException | IllegalTypeException | IllegalArgumentException ex) { LOGGER.warn("Problem modifying citation", ex); JOptionPane.showMessageDialog(frame, Localization.lang("Problem modifying citation")); } diag.dispose(); }); Action cancelAction = new AbstractAction() { @Override public void actionPerformed(ActionEvent actionEvent) { diag.dispose(); } }; cancel.addActionListener(cancelAction); bb.getPanel().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW) .put(Globals.getKeyPrefs().getKey(KeyBinding.CLOSE_DIALOG), "close"); bb.getPanel().getActionMap().put("close", cancelAction); table.getColumnModel().getColumn(0).setPreferredWidth(600); table.getColumnModel().getColumn(1).setPreferredWidth(90); table.setPreferredScrollableViewportSize(new Dimension(700, 500)); table.addMouseListener(new TableClickListener()); }
From source file:org.geopublishing.atlasStyler.swing.PolygonSymbolEditGUI.java
/** * This method initializes jComboBox/* www . ja v a 2s .c o m*/ * * @return javax.swing.JComboBox */ private ColorButton getJButtonFillColor() { if (jButtonFillColor == null) { jButtonFillColor = new ColorButton(); jButtonFillColor.setAction(new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { Fill fill = symbolizer.getFill(); Color color = null; if (fill != null && fill.getColor() != null) { String substring = fill.getColor().toString(); color = Color.decode(substring); } // Color newColor = JColorChooser.showDialog( // PolygonSymbolEditGUI.this, "Choose fill color", // color); // i8nAC Color newColor = AVSwingUtil.showColorChooser(PolygonSymbolEditGUI.this, AtlasStylerVector.R("Fill.ColorChooserDialog.Title"), color); if (newColor != null && newColor != color) { String rgb = Integer.toHexString(newColor.getRGB()); rgb = "#" + rgb.substring(2, rgb.length()); fill.setColor(ASUtil.ff2.literal(rgb)); PolygonSymbolEditGUI.this.firePropertyChange(PROPERTY_UPDATED, null, null); jButtonFillColor.setColor(newColor); } } }); Fill f = symbolizer.getFill(); if (f != null) { jButtonFillColor.setColor(StylingUtil.getColorFromExpression(f.getColor())); } else { jButtonFillColor.setColor((Color) null); jPanelFill.setEnabled(false); } } return jButtonFillColor; }
From source file:org.ngrinder.recorder.ui.AboutDialog.java
private void initKeyStroke() { addKeyListener(new KeyAdapter() { @Override// w w w . j ava 2s. com public void keyPressed(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_ESCAPE) { dispose(); } } }); JRootPane rootPane = getRootPane(); rootPane.getActionMap().put("ESCAPE", new AbstractAction() { private static final long serialVersionUID = 421791976774749694L; public void actionPerformed(ActionEvent e) { dispose(); } }); KeyStroke keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0, false); rootPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(keyStroke, "ESCAPE"); }
From source file:net.sf.jabref.gui.openoffice.CitationManager.java
public CitationManager(final JabRefFrame frame, OOBibBase ooBase) throws NoSuchElementException, WrappedTargetException, UnknownPropertyException { diag = new JDialog(frame, Localization.lang("Manage citations"), true); this.ooBase = ooBase; list = new BasicEventList<>(); XNameAccess nameAccess = ooBase.getReferenceMarks(); List<String> names = ooBase.getJabRefReferenceMarks(nameAccess); for (String name : names) { list.add(new CitationEntry(name, "<html>..." + ooBase.getCitationContext(nameAccess, name, 30, 30, true) + "...</html>", ooBase.getCustomProperty(name))); }/*from w w w . j a va 2 s .c o m*/ tableModel = new DefaultEventTableModel<>(list, new CitationEntryFormat()); table = new JTable(tableModel); diag.add(new JScrollPane(table), BorderLayout.CENTER); ButtonBarBuilder bb = new ButtonBarBuilder(); bb.addGlue(); JButton ok = new JButton(Localization.lang("OK")); bb.addButton(ok); JButton cancel = new JButton(Localization.lang("Cancel")); bb.addButton(cancel); bb.addGlue(); bb.getPanel().setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); diag.add(bb.getPanel(), BorderLayout.SOUTH); diag.pack(); diag.setSize(700, 400); ok.addActionListener(e -> { try { storeSettings(); } catch (UnknownPropertyException | NotRemoveableException | PropertyExistException | IllegalTypeException | IllegalArgumentException ex) { LOGGER.warn("Problem modifying citation", ex); JOptionPane.showMessageDialog(frame, Localization.lang("Problem modifying citation")); } diag.dispose(); }); Action cancelAction = new AbstractAction() { @Override public void actionPerformed(ActionEvent actionEvent) { diag.dispose(); } }; cancel.addActionListener(cancelAction); bb.getPanel().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW) .put(Globals.getKeyPrefs().getKey(KeyBinding.CLOSE_DIALOG), "close"); bb.getPanel().getActionMap().put("close", cancelAction); table.getColumnModel().getColumn(0).setPreferredWidth(580); table.getColumnModel().getColumn(1).setPreferredWidth(110); table.setPreferredScrollableViewportSize(new Dimension(700, 500)); table.addMouseListener(new TableClickListener()); }
From source file:org.notebook.gui.widget.GuiUtils.java
/** * Adds the close action with escape key. * // w ww. j av a2 s . c o m * @param frame * the frame */ public static void addCloseActionWithEscapeKey(final JFrame frame) { // Handle escape key to close the dialog KeyStroke escape = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0, false); Action escapeAction = new AbstractAction() { private static final long serialVersionUID = 0L; @Override public void actionPerformed(ActionEvent e) { frame.setVisible(false); } }; frame.getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(escape, "ESCAPE"); frame.getRootPane().getActionMap().put("ESCAPE", escapeAction); }
From source file:org.pgptool.gui.ui.keyslist.KeysTableView.java
@SuppressWarnings("serial") private void initTableKeyListener() { int condition = JComponent.WHEN_IN_FOCUSED_WINDOW; InputMap inputMap = table.getInputMap(condition); ActionMap actionMap = table.getActionMap(); inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0), DELETE); actionMap.put(DELETE, new AbstractAction() { @Override// w ww .j av a 2 s. c om public void actionPerformed(ActionEvent e) { if (pm == null) { return; } safePerformAction(pm.getActionDelete(), null); } }); }