List of usage examples for javax.swing AbstractAction AbstractAction
public AbstractAction()
From source file:fi.smaa.jsmaa.gui.SMAATRIGUIFactory.java
private JMenu buildCategoryMenu() { JMenu categoryMenu = new JMenu("Categories"); categoryMenu.setMnemonic('t'); JMenuItem showItem = new JMenuItem("Show"); showItem.setMnemonic('s'); JMenuItem addCatButton = createAddCatMenuItem(); showItem.addActionListener(new AbstractAction() { public void actionPerformed(ActionEvent e) { Focuser.focus(tree, treeModel, treeModel.getCategoriesNode()); }/*from w ww . j a v a 2 s .co m*/ }); categoryMenu.add(showItem); categoryMenu.addSeparator(); categoryMenu.add(addCatButton); return categoryMenu; }
From source file:net.sf.jabref.wizard.auximport.gui.FromAuxDialog.java
private void jbInit() { JPanel panel1 = new JPanel(); panel1.setLayout(new BorderLayout()); selectInDBButton.setText(Localization.lang("Select")); selectInDBButton.setEnabled(false);// w w w .j a v a 2s. c o m selectInDBButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { FromAuxDialog.this.select_actionPerformed(); } }); generateButton.setText(Localization.lang("Generate")); generateButton.setEnabled(false); generateButton.addActionListener(new FromAuxDialog_generate_actionAdapter(this)); cancelButton.setText(Localization.lang("Cancel")); cancelButton.addActionListener(new FromAuxDialog_Cancel_actionAdapter(this)); parseButton.setText(Localization.lang("Parse")); parseButton.addActionListener(new FromAuxDialog_parse_actionAdapter(this)); initPanels(); // insert the buttons ButtonBarBuilder bb = new ButtonBarBuilder(); JPanel buttonPanel = bb.getPanel(); buttonPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); bb.addGlue(); bb.addButton(parseButton); bb.addRelatedGap(); bb.addButton(selectInDBButton); bb.addButton(generateButton); bb.addButton(cancelButton); bb.addGlue(); this.setModal(true); this.setResizable(true); this.setTitle(Localization.lang("AUX file import")); JLabel desc = new JLabel("<html><h3>" + Localization.lang("AUX file import") + "</h3><p>" + Localization.lang("This feature generates a new database based on which entries " + "are needed in an existing LaTeX document.") + "</p>" + "<p>" + Localization.lang("You need to select one of your open databases from which to choose " + "entries, as well as the AUX file produced by LaTeX when compiling your document.") + "</p></html>"); desc.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); panel1.add(desc, BorderLayout.NORTH); JPanel centerPane = new JPanel(new BorderLayout()); centerPane.add(buttons, BorderLayout.NORTH); centerPane.add(statusPanel, BorderLayout.CENTER); getContentPane().add(panel1, BorderLayout.NORTH); getContentPane().add(centerPane, BorderLayout.CENTER); getContentPane().add(buttonPanel, BorderLayout.SOUTH); // Key bindings: ActionMap am = statusPanel.getActionMap(); InputMap im = statusPanel.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW); im.put(Globals.getKeyPrefs().getKey(KeyBinding.CLOSE_DIALOG), "close"); am.put("close", new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { dispose(); } }); }
From source file:de.mprengemann.intellij.plugin.androidicons.forms.AndroidBatchScaleImporter.java
public AndroidBatchScaleImporter(final Project project, final Module module) { super(project); this.project = project; this.module = module; setTitle("Android Scale Importer"); setResizable(false);/*w w w.ja va 2 s . c o m*/ final FileType imageFileType = ImageFileTypeManager.getInstance().getImageFileType(); final FileChooserDescriptor imageDescriptor = new FileChooserDescriptor(true, true, false, false, false, false) { public boolean isFileVisible(VirtualFile file, boolean showHiddenFiles) { return file.isDirectory() || file.getFileType() == imageFileType; } public boolean isFileSelectable(VirtualFile file) { return super.isFileSelectable(file) && file.getFileType() == imageFileType; } }; addButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { FileChooser.chooseFile(imageDescriptor, project, getInitialFile(), new Consumer<VirtualFile>() { @Override public void consume(final VirtualFile file) { SettingsHelper.saveLastImageFolder(project, file.getCanonicalPath()); if (resRoot == null) { AndroidResourcesHelper.getResRootFile(project, module, new ResourcesDialog.ResourceSelectionListener() { @Override public void onResourceSelected(VirtualFile resDir) { resRoot = resDir; SettingsHelper.saveResRootForProject(project, resDir.getUrl()); addImageFiles(file); } }); } else { addImageFiles(file); } } }); } }); deleteButton.addActionListener(new AbstractAction() { @Override public void actionPerformed(ActionEvent actionEvent) { int selectedRow = table.getSelectedRow(); if (selectedRow >= 0) { tableModel.removeItem(selectedRow); imageContainer.setIcon(null); updateTargetSizes(null); } } }); algorithmSpinner.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { ResizeAlgorithm algorithm = ResizeAlgorithm.from((String) algorithmSpinner.getSelectedItem()); methodSpinner.removeAllItems(); for (String method : algorithm.getMethods()) { methodSpinner.addItem(method); } } }); for (ResizeAlgorithm algorithms : ResizeAlgorithm.values()) { algorithmSpinner.addItem(algorithms.toString()); } new FileDrop(table, new FileDrop.Target() { @Override public FileChooserDescriptor getDescriptor() { return imageDescriptor; } @Override public boolean isHiddenShown() { return false; } @Override public void dropFiles(final List<VirtualFile> virtualFiles) { if (virtualFiles == null) { return; } if (resRoot == null) { AndroidResourcesHelper.getResRootFile(project, module, new ResourcesDialog.ResourceSelectionListener() { @Override public void onResourceSelected(VirtualFile resDir) { resRoot = resDir; SettingsHelper.saveResRootForProject(project, resDir.getUrl()); for (VirtualFile file : virtualFiles) { addImageFiles(file); } } }); } else { for (VirtualFile file : virtualFiles) { addImageFiles(file); } } } }); initTable(); init(); }
From source file:fi.smaa.jsmaa.gui.SMAA2GUIFactory.java
private JMenuItem createAddScaleCriterionItem() { JMenuItem cardCrit = new JMenuItem("Cardinal"); cardCrit.setIcon(ImageFactory.IMAGELOADER.getIcon(FileNames.ICON_CARDINALCRITERION)); cardCrit.addActionListener(new AbstractAction() { public void actionPerformed(ActionEvent e) { addCriterionAndStartRename(new ScaleCriterion(generateNextCriterionName())); }//from w w w .ja v a 2 s . c om }); return cardCrit; }
From source file:fr.duminy.components.swing.listpanel.SimpleItemManagerTest.java
private ItemManager<Bean> createItemManagerAndCreateItemAction(ContainerType containerType, NameType nameType) { return createItemManager(containerType, new AbstractAction() { @Override/* ww w .jav a 2s.c o m*/ public void actionPerformed(ActionEvent e) { addCallback(manager.createItem(), "create"); } @Override public String toString() { return "AbstractAction('create')"; } }, nameType); }
From source file:org.cds06.speleograph.graph.ValueAxisEditor.java
/** * {@inheritDoc}// w ww .j av a2 s . c om */ @Override protected void setup() { PanelBuilder builder = new PanelBuilder(getFormLayout(), getPanel()); CellConstraints cc = new CellConstraints(); Dimension d = maxModifier.getPreferredSize(); maxModifier.setPreferredSize(new Dimension(d.width + 50, d.height)); d = minModifier.getPreferredSize(); minModifier.setPreferredSize(new Dimension(d.width + 50, d.height)); { builder.add(new JLabel("Titre de l'axe :")); final JTextField axisTitleField = new JTextField(); axisTitleField.setText(axis.getLabel()); builder.nextColumn(2); builder.add(axisTitleField, cc.xyw(3, 1, 5)); addListenerOnSuccess(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { String text = axisTitleField.getText(); if (text != null && !text.equals("")) axis.setLabel(axisTitleField.getText()); } }); } { builder.nextLine(2); builder.add(new JLabel("Valeur min. :")); builder.nextColumn(2); builder.add(lowField); addListenerOnSuccess(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { try { Double value = Double.valueOf(lowField.getText()); if (isApply) { axis.setLowerBound(value); } else if (isCancel && oldLowValue != null) axis.setLowerBound(oldLowValue); } catch (NumberFormatException e1) { canClose = false; JOptionPane.showMessageDialog(ValueAxisEditor.this.getParent(), "'" + lowField.getText() + "' n'est pas un nombre", "Erreur", JOptionPane.ERROR_MESSAGE); } } }); builder.nextColumn(2); builder.add(new JLabel("+")); builder.nextColumn(2); builder.add(minModifier); } { builder.nextLine(2); builder.add(new JLabel("Valeur max. :")); builder.nextColumn(2); builder.add(maxField); addListenerOnSuccess(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { try { Double value = Double.valueOf(maxField.getText()); if (isApply) { axis.setUpperBound(value); } else if (isCancel && oldHighValue != null) axis.setUpperBound(oldHighValue); } catch (NumberFormatException e1) { canClose = false; JOptionPane.showMessageDialog(ValueAxisEditor.this.getParent(), "'" + maxField.getText() + "' n'est pas un nombre", "Erreur", JOptionPane.ERROR_MESSAGE); } } }); builder.nextColumn(2); builder.add(new JLabel("+")); builder.nextColumn(2); builder.add(maxModifier); } { builder.nextLine(2); builder.add(new JLabel("<HTML><strong>Sries associes l'axe</strong></HTML>"), cc.xyw(1, 7, 3)); String linkedSeries = "<html><ul>"; for (Series series : Series.getInstances()) { if (series.getAxis().equals(axis)) linkedSeries += "<li>" + series.toString(true) + "</li>"; } linkedSeries += "</ul></html>"; builder.add(new JLabel(linkedSeries), cc.xyw(1, 8, 3)); } JPanel buttonPanel = new JPanel(); ButtonBarBuilder buttonBuilder = new ButtonBarBuilder(buttonPanel); buttonBuilder.addGlue(); { buttonBuilder.addButton(new AbstractAction() { { putValue(NAME, I18nSupport.translate("cancel")); } @Override public void actionPerformed(ActionEvent e) { isCancel = true; isApply = false; canClose = true; validateForm(); } }); } { buttonBuilder.addButton(new AbstractAction() { { putValue(NAME, I18nSupport.translate("apply")); } @Override public void actionPerformed(ActionEvent e) { isCancel = false; isApply = true; canClose = false; validateForm(); } }); } { buttonBuilder.addButton(new AbstractAction() { { putValue(NAME, I18nSupport.translate("ok")); } @Override public void actionPerformed(ActionEvent e) { isCancel = false; isApply = true; canClose = true; validateForm(); } }); } buttonBuilder.build(); buttonPanel.setVisible(true); builder.add(buttonBuilder.getPanel(), cc.xyw(1, 10, 10)); { translateSlider.setToolTipText("Translation des axes"); translateSlider.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { int maxValue = -translateSlider.getValue(); maxModifier.setText(String.valueOf(maxValue)); int lowValue = -translateSlider.getValue(); minModifier.setText(String.valueOf(lowValue)); } }); builder.add(translateSlider, cc.xywh(9, 1, 1, 8)); } { homotSlider.setToolTipText("Homothtie sur les axes"); homotSlider.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { int maxValue = -homotSlider.getValue(); maxModifier.setText(String.valueOf(maxValue)); int lowValue = homotSlider.getValue(); minModifier.setText(String.valueOf(lowValue)); } }); builder.add(homotSlider, cc.xywh(10, 1, 1, 8)); } builder.build(); getPanel().setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2)); addListenerOnSuccess(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (canClose) setVisible(false); } }); }
From source file:net.sf.jabref.gui.search.SearchResultsDialog.java
private void init(String title) { diag = new JDialog(frame, title, false); int activePreview = Globals.prefs.getInt(JabRefPreferences.ACTIVE_PREVIEW); String layoutFile = activePreview == 0 ? Globals.prefs.get(JabRefPreferences.PREVIEW_0) : Globals.prefs.get(JabRefPreferences.PREVIEW_1); preview = new PreviewPanel(null, null, layoutFile); sortedEntries = new SortedList<>(entries, new EntryComparator(false, true, FieldName.AUTHOR)); model = (DefaultEventTableModel<BibEntry>) GlazedListsSwing .eventTableModelWithThreadProxyList(sortedEntries, new EntryTableFormat()); entryTable = new JTable(model); GeneralRenderer renderer = new GeneralRenderer(Color.white); entryTable.setDefaultRenderer(JLabel.class, renderer); entryTable.setDefaultRenderer(String.class, renderer); setWidths();/*from w w w . jav a 2 s.c o m*/ TableComparatorChooser<BibEntry> tableSorter = TableComparatorChooser.install(entryTable, sortedEntries, AbstractTableComparatorChooser.MULTIPLE_COLUMN_KEYBOARD); setupComparatorChooser(tableSorter); JScrollPane sp = new JScrollPane(entryTable); final DefaultEventSelectionModel<BibEntry> selectionModel = (DefaultEventSelectionModel<BibEntry>) GlazedListsSwing .eventSelectionModelWithThreadProxyList(sortedEntries); entryTable.setSelectionModel(selectionModel); selectionModel.getSelected().addListEventListener(new EntrySelectionListener()); entryTable.addMouseListener(new TableClickListener()); contentPane.setTopComponent(sp); contentPane.setBottomComponent(preview); // Key bindings: AbstractAction closeAction = new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { diag.dispose(); } }; ActionMap am = contentPane.getActionMap(); InputMap im = contentPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW); im.put(Globals.getKeyPrefs().getKey(KeyBinding.CLOSE_DIALOG), "close"); am.put("close", closeAction); entryTable.getActionMap().put("copy", new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { if (!selectionModel.getSelected().isEmpty()) { List<BibEntry> bes = selectionModel.getSelected(); TransferableBibtexEntry trbe = new TransferableBibtexEntry(bes); // ! look at ClipBoardManager Toolkit.getDefaultToolkit().getSystemClipboard().setContents(trbe, frame.getCurrentBasePanel()); frame.output(Localization.lang("Copied") + ' ' + (bes.size() > 1 ? bes.size() + " " + Localization.lang("entries") : "1 " + Localization.lang("entry") + '.')); } } }); diag.addWindowListener(new WindowAdapter() { @Override public void windowOpened(WindowEvent e) { contentPane.setDividerLocation(0.5f); } @Override public void windowClosing(WindowEvent event) { Globals.prefs.putInt(JabRefPreferences.SEARCH_DIALOG_WIDTH, diag.getSize().width); Globals.prefs.putInt(JabRefPreferences.SEARCH_DIALOG_HEIGHT, diag.getSize().height); } }); diag.getContentPane().add(contentPane, BorderLayout.CENTER); // Remember and default to last size: diag.setSize(new Dimension(Globals.prefs.getInt(JabRefPreferences.SEARCH_DIALOG_WIDTH), Globals.prefs.getInt(JabRefPreferences.SEARCH_DIALOG_HEIGHT))); diag.setLocationRelativeTo(frame); }
From source file:net.sf.jabref.gui.FileListEntryEditor.java
public FileListEntryEditor(JabRefFrame frame, FileListEntry entry, boolean showProgressBar, boolean showOpenButton, BibDatabaseContext databaseContext) { this.entry = entry; this.databaseContext = databaseContext; ActionListener okAction = e -> { // If OK button is disabled, ignore this event: if (!ok.isEnabled()) { return; }/*from w w w .jav a 2 s .c om*/ // If necessary, ask the external confirm object whether we are ready to close. if (externalConfirm != null) { // Construct an updated FileListEntry: storeSettings(entry); if (!externalConfirm.confirmClose(entry)) { return; } } diag.dispose(); storeSettings(FileListEntryEditor.this.entry); okPressed = true; }; types = new JComboBox<>(); types.addItemListener(itemEvent -> { if (!okDisabledExternally) { ok.setEnabled(types.getSelectedItem() != null); } }); FormBuilder builder = FormBuilder.create().layout(new FormLayout( "left:pref, 4dlu, fill:150dlu, 4dlu, fill:pref, 4dlu, fill:pref", "p, 2dlu, p, 2dlu, p")); builder.add(Localization.lang("Link")).xy(1, 1); builder.add(link).xy(3, 1); final BrowseListener browse = new BrowseListener(frame, link); final JButton browseBut = new JButton(Localization.lang("Browse")); browseBut.addActionListener(browse); builder.add(browseBut).xy(5, 1); JButton open = new JButton(Localization.lang("Open")); if (showOpenButton) { builder.add(open).xy(7, 1); } builder.add(Localization.lang("Description")).xy(1, 3); builder.add(description).xyw(3, 3, 3); builder.getPanel().setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); builder.add(Localization.lang("File type")).xy(1, 5); builder.add(types).xyw(3, 5, 3); if (showProgressBar) { builder.appendRows("2dlu, p"); builder.add(downloadLabel).xy(1, 7); builder.add(prog).xyw(3, 7, 3); } ButtonBarBuilder bb = new ButtonBarBuilder(); bb.addGlue(); bb.addRelatedGap(); bb.addButton(ok); JButton cancel = new JButton(Localization.lang("Cancel")); bb.addButton(cancel); bb.addGlue(); bb.getPanel().setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); ok.addActionListener(okAction); // Add OK action to the two text fields to simplify entering: link.addActionListener(okAction); description.addActionListener(okAction); open.addActionListener(e -> openFile()); AbstractAction cancelAction = new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { diag.dispose(); } }; cancel.addActionListener(cancelAction); // Key bindings: ActionMap am = builder.getPanel().getActionMap(); InputMap im = builder.getPanel().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW); im.put(Globals.getKeyPrefs().getKey(KeyBinding.CLOSE_DIALOG), "close"); am.put("close", cancelAction); link.getDocument().addDocumentListener(new DocumentListener() { @Override public void insertUpdate(DocumentEvent documentEvent) { checkExtension(); } @Override public void removeUpdate(DocumentEvent documentEvent) { // Do nothing } @Override public void changedUpdate(DocumentEvent documentEvent) { checkExtension(); } }); diag = new JDialog(frame, Localization.lang("Save file"), true); diag.getContentPane().add(builder.getPanel(), BorderLayout.CENTER); diag.getContentPane().add(bb.getPanel(), BorderLayout.SOUTH); diag.pack(); diag.setLocationRelativeTo(frame); diag.addWindowListener(new WindowAdapter() { @Override public void windowActivated(WindowEvent event) { if (openBrowseWhenShown && !dontOpenBrowseUntilDisposed) { dontOpenBrowseUntilDisposed = true; SwingUtilities.invokeLater(() -> browse.actionPerformed(new ActionEvent(browseBut, 0, ""))); } } @Override public void windowClosed(WindowEvent event) { dontOpenBrowseUntilDisposed = false; } }); setValues(entry); }
From source file:edu.ucla.stat.SOCR.chart.demo.SOCR_EM_MixtureModelChartDemo.java
protected void createActionComponents(JToolBar toolBar) { super.createActionComponents(toolBar); JButton button;/*from ww w . ja va2s.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_2D_PointSegmentation_EM_Mixture"), "SOCR EduMaterials Activities 2D PointSegmentation EM Mixture"); } 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 2D PointSegmentation EM Mixture Activity wiki page"); }
From source file:edu.ku.brc.af.ui.forms.ResultSetController.java
/** * //from w w w . ja v a 2 s .co m */ public void setupGotoListener() { KeyStroke gotoKS = KeyStroke.getKeyStroke(KeyEvent.VK_L, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()); String ACTION_KEY = "GOTO"; InputMap inputMap = panel.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW); ActionMap actionMap = panel.getActionMap(); inputMap.put(gotoKS, ACTION_KEY); actionMap.put(ACTION_KEY, new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { showGotoRecDlg(); } }); }