List of usage examples for javax.swing Action SMALL_ICON
String SMALL_ICON
To view the source code for javax.swing Action SMALL_ICON.
Click Source Link
Icon
, such as ImageIcon
. From source file:Main.java
/** * /*ww w .j av a 2s . c o m*/ * TODO * @param action * @return */ public static AbstractButton createToolbarItem(Action action) { final AbstractButton button; if (action == null) { throw new NullPointerException("Action cannot be null!"); } else if (action.getValue(Action.SELECTED_KEY) != null) { button = new JToggleButton(action); } else { button = new JButton(action); } button.setOpaque(false); // hide text if icon is available if (action != null && (action.getValue(Action.SMALL_ICON) != null || action.getValue(Action.LARGE_ICON_KEY) != null)) { button.setHideActionText(true); } button.setHorizontalTextPosition(JButton.CENTER); button.setVerticalTextPosition(JButton.BOTTOM); return button; }
From source file:clipboardplugin.ClipboardPlugin.java
public ActionMenu getContextMenuActions(final Program program) { ImageIcon img = createImageIcon("actions", "edit-paste", 16); if (mConfigs.length > 1) { ContextMenuAction copyToSystem = new ContextMenuAction( mLocalizer.ellipsisMsg("copyToSystem", "Copy to system clipboard")); ArrayList<AbstractAction> list = new ArrayList<AbstractAction>(); for (final AbstractPluginProgramFormating config : mConfigs) { if (config != null && config.isValid()) { final Program[] programs = { program }; AbstractAction copyAction = new AbstractAction(config.getName()) { public void actionPerformed(ActionEvent e) { copyProgramsToSystem(programs, config); }//from w w w. java2 s .c om }; String text = getTextForConfig(programs, config); copyAction.setEnabled(text == null || StringUtils.isNotEmpty(text)); list.add(copyAction); } } copyToSystem.putValue(Action.SMALL_ICON, img); return new ActionMenu(copyToSystem, list.toArray(new AbstractAction[list.size()])); } else { AbstractAction copyToSystem = new AbstractAction( mLocalizer.msg("copyToSystem", "Copy to system clipboard")) { public void actionPerformed(ActionEvent evt) { Program[] list = { program }; copyProgramsToSystem(list, mConfigs.length != 1 ? DEFAULT_CONFIG : mConfigs[0]); } }; copyToSystem.putValue(Action.SMALL_ICON, img); return new ActionMenu(copyToSystem); } }
From source file:com.diversityarrays.kdxplore.vistool.VisToolbarFactory.java
static public VisToolToolBar create(final String title, final JComponent comp, final Closure<File> snapshotter, final VisToolDataProvider visToolDataProvider, boolean floatable, final String[] imageSuffixes) { Window window = GuiUtil.getOwnerWindow(comp); boolean anyButtons = false; final JCheckBox keepOnTop; if (window == null) { keepOnTop = null;/* w w w . j a va2 s. c o m*/ } else { anyButtons = true; keepOnTop = new JCheckBox(Msg.OPTION_KEEP_ON_TOP(), true); keepOnTop.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { window.setAlwaysOnTop(keepOnTop.isSelected()); } }); window.setAlwaysOnTop(keepOnTop.isSelected()); // buttons.add(keepOnTop); final PropertyChangeListener alwaysOnTopListener = new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { keepOnTop.setSelected(window.isAlwaysOnTop()); } }; window.addPropertyChangeListener(PROPERTY_ALWAYS_ON_TOP, alwaysOnTopListener); window.addWindowListener(new WindowAdapter() { @Override public void windowClosed(WindowEvent e) { window.removeWindowListener(this); window.removePropertyChangeListener(PROPERTY_ALWAYS_ON_TOP, alwaysOnTopListener); } }); } final JButton cameraButton; if (snapshotter == null) { cameraButton = null; } else { Action cameraAction = new AbstractAction(Msg.ACTION_SNAPSHOT()) { @Override public void actionPerformed(ActionEvent e) { if (chooser == null) { chooser = new JFileChooser(); chooser.setFileFilter(new FileFilter() { @Override public boolean accept(File f) { if (!f.isFile()) { return true; } String loname = f.getName().toLowerCase(); for (String sfx : imageSuffixes) { if (loname.endsWith(sfx)) { return true; } } return false; } @Override public String getDescription() { return Msg.DESC_IMAGE_FILE(); } }); chooser.setMultiSelectionEnabled(false); chooser.setFileSelectionMode(JFileChooser.FILES_ONLY); } if (JFileChooser.APPROVE_OPTION == chooser.showSaveDialog(comp)) { File file = chooser.getSelectedFile(); snapshotter.execute(file); } } }; ImageIcon icon = loadIcon("camera-24.png"); //$NON-NLS-1$ if (icon != null) { cameraAction.putValue(Action.SMALL_ICON, icon); cameraAction.putValue(Action.NAME, null); } anyButtons = true; cameraButton = new JButton(cameraAction); } final JButton refreshButton; if (visToolDataProvider == null) { refreshButton = null; } else { anyButtons = true; refreshButton = new JButton(Msg.ACTION_REFRESH()); ImageIcon icon = loadIcon("refresh-24.png"); //$NON-NLS-1$ if (icon != null) { refreshButton.setIcon(icon); // don't remove the name } refreshButton.setForeground(Color.RED); refreshButton.setEnabled(false); refreshButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (visToolDataProvider.refreshData()) { refreshButton.setEnabled(false); } } }); visToolDataProvider.addVisToolDataChangedListener(new VisToolDataChangedListener() { @Override public void visToolDataChanged(Object source) { refreshButton.setEnabled(true); } }); } VisToolToolBar toolBar = null; if (anyButtons) { toolBar = new VisToolToolBar(keepOnTop, cameraButton, refreshButton); toolBar.setFloatable(floatable); } return toolBar; }
From source file:userinterface.graph.SeriesEditorDialog.java
/** Creates new form GUIConstantsPicker */ private SeriesEditorDialog(GUIPlugin plugin, JFrame parent, JPanel graph, java.util.List<SeriesKey> series) { super(parent, "Graph Series Editor", true); this.plugin = plugin; this.editors = new ArrayList<SeriesEditor>(); initComponents();/*from w w w . j a va2s .c o m*/ AbstractAction cut = new AbstractAction() { public void actionPerformed(ActionEvent e) { editors.get(tabbedPane.getSelectedIndex()).cut(); } }; cut.putValue(Action.LONG_DESCRIPTION, "Cut the current selection to the clipboard"); //exitAction.putValue(Action.SHORT_DESCRIPTION, "Exit"); cut.putValue(Action.NAME, "Cut"); cut.putValue(Action.SMALL_ICON, GUIPrism.getIconFromImage("smallCut.png")); //cut.putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_X, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); AbstractAction copy = new AbstractAction() { public void actionPerformed(ActionEvent e) { editors.get(tabbedPane.getSelectedIndex()).copy(); } }; copy.putValue(Action.LONG_DESCRIPTION, "Copies the current selection to the clipboard"); //exitAction.putValue(Action.SHORT_DESCRIPTION, "Exit"); copy.putValue(Action.NAME, "Copy"); copy.putValue(Action.SMALL_ICON, GUIPrism.getIconFromImage("smallCopy.png")); //copy.putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_C, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); AbstractAction paste = new AbstractAction() { public void actionPerformed(ActionEvent e) { editors.get(tabbedPane.getSelectedIndex()).paste(); } }; paste.putValue(Action.LONG_DESCRIPTION, "Pastes the clipboard to the current selection"); //exitAction.putValue(Action.SHORT_DESCRIPTION, "Exit"); paste.putValue(Action.NAME, "Paste"); paste.putValue(Action.SMALL_ICON, GUIPrism.getIconFromImage("smallPaste.png")); //paste.putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_V, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); AbstractAction delete = new AbstractAction() { public void actionPerformed(ActionEvent e) { editors.get(tabbedPane.getSelectedIndex()).delete(); } }; delete.putValue(Action.LONG_DESCRIPTION, "Deletes the current"); //exitAction.putValue(Action.SHORT_DESCRIPTION, "Exit"); delete.putValue(Action.NAME, "Delete"); delete.putValue(Action.SMALL_ICON, GUIPrism.getIconFromImage("smallDelete.png")); for (SeriesKey key : series) { SeriesSettings settings = null; if (graph instanceof Graph) settings = ((Graph) graph).getGraphSeries(key); if (graph instanceof Histogram) settings = ((Histogram) graph).getGraphSeries(key); if (graph instanceof Graph3D) settings = ((Graph3D) graph).getSeriesSettings(); Object DataSeries = null; if (graph instanceof Graph) DataSeries = (PrismXYSeries) ((Graph) graph).getXYSeries(key); if (graph instanceof Histogram) DataSeries = ((Histogram) graph).getXYSeries(key); if (graph instanceof Graph3D) DataSeries = ((Graph3D) graph).getScatterSeries(); SeriesEditor editor = new SeriesEditor(graph, DataSeries, settings, cut, copy, paste, delete); editor.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); tabbedPane.addTab(settings.getSeriesHeading(), editor); editors.add(editor); } this.getRootPane().setDefaultButton(okayButton); toolBar.add(cut); toolBar.add(copy); toolBar.add(paste); toolBar.add(delete); this.add(toolBar, BorderLayout.NORTH); this.cancelled = false; super.setBounds(new Rectangle(550, 300)); setResizable(true); setLocationRelativeTo(getParent()); // centre }
From source file:captureplugin.CapturePlugin.java
public ActionMenu getContextMenuActions(final Program program) { final DeviceIf[] devices = mConfig.getDeviceArray(); final Window parent = UiUtilities.getLastModalChildOf(getParentFrame()); Action mainaction = new devplugin.ContextMenuAction(); mainaction.putValue(Action.NAME, mLocalizer.msg("record", "record Program")); mainaction.putValue(Action.SMALL_ICON, createImageIcon("mimetypes", "video-x-generic", 16)); ArrayList<ActionMenu> actionList = new ArrayList<ActionMenu>(); for (final DeviceIf dev : devices) { Action action = new ContextMenuAction(); action.putValue(Action.NAME, dev.getName()); ArrayList<AbstractAction> commandList = new ArrayList<AbstractAction>(); if (dev.isAbleToAddAndRemovePrograms()) { final Program test = dev.getProgramForProgramInList(program); if (test != null) { AbstractAction caction = new AbstractAction() { public void actionPerformed(ActionEvent evt) { dev.remove(parent, test); updateMarkedPrograms(); }//w ww .j a v a 2 s .co m }; caction.putValue(Action.NAME, Localizer.getLocalization(Localizer.I18N_DELETE)); commandList.add(caction); } else { AbstractAction caction = new AbstractAction() { public void actionPerformed(ActionEvent evt) { if (dev.add(parent, program)) { dev.sendProgramsToReceiveTargets(new Program[] { program }); } updateMarkedPrograms(); } }; caction.putValue(Action.NAME, mLocalizer.msg("record", "record")); commandList.add(caction); } } String[] commands = dev.getAdditionalCommands(); if (commands != null) { for (int y = 0; y < commands.length; y++) { final int num = y; AbstractAction caction = new AbstractAction() { public void actionPerformed(ActionEvent evt) { dev.executeAdditionalCommand(parent, num, program); } }; caction.putValue(Action.NAME, commands[y]); commandList.add(caction); } } if (!commandList.isEmpty()) { actionList.add(new ActionMenu(action, commandList.toArray(new Action[commandList.size()]))); } } if (actionList.size() == 1) { ActionMenu menu = actionList.get(0); if (menu.getSubItems().length == 0) { return null; } if (menu.getSubItems().length == 1) { Action action = menu.getSubItems()[0].getAction(); action.putValue(Action.SMALL_ICON, createImageIcon("mimetypes", "video-x-generic", 16)); return new ActionMenu(action); } else { mainaction.putValue(Action.NAME, menu.getTitle()); return new ActionMenu(mainaction, menu.getSubItems()); } } ActionMenu[] actions = new ActionMenu[actionList.size()]; actionList.toArray(actions); if (actions.length == 0) { return null; } return new ActionMenu(mainaction, actions); }
From source file:userinterface.properties.GUIGraphHandler.java
private void initComponents() { theTabs = new JTabbedPane() { @Override/*from w w w. ja va 2s . c o m*/ public String getTitleAt(int index) { try { TabClosePanel panel = (TabClosePanel) getTabComponentAt(index); return panel.getTitle(); } catch (Exception e) { return ""; } } @Override public String getToolTipTextAt(int index) { return ((TabClosePanel) getTabComponentAt(index)).getToolTipText(); } @Override public void setTitleAt(int index, String title) { if (((TabClosePanel) getTabComponentAt(index)) == null) { return; } ((TabClosePanel) getTabComponentAt(index)).setTitle(title); } @Override public void setIconAt(int index, Icon icon) { ((TabClosePanel) getTabComponentAt(index)).setIcon(icon); } @Override public void setToolTipTextAt(int index, String toolTipText) { ((TabClosePanel) getTabComponentAt(index)).setToolTip(toolTipText); } }; theTabs.addMouseListener(this); theTabs.addMouseWheelListener(new MouseWheelListener() { @Override public void mouseWheelMoved(MouseWheelEvent e) { if (e.getPreciseWheelRotation() > 0.0) { if (theTabs.getSelectedIndex() != (theTabs.getTabCount() - 1)) theTabs.setSelectedIndex(theTabs.getSelectedIndex() + 1); } else { if (theTabs.getSelectedIndex() != 0) theTabs.setSelectedIndex(theTabs.getSelectedIndex() - 1); } } }); setLayout(new BorderLayout()); add(theTabs, BorderLayout.CENTER); graphOptions = new AbstractAction() { public void actionPerformed(ActionEvent e) { GraphOptions graphOptions = options.get(theTabs.getSelectedIndex()); graphOptions.setVisible(true); } }; graphOptions.putValue(Action.NAME, "Graph options"); graphOptions.putValue(Action.MNEMONIC_KEY, new Integer(KeyEvent.VK_G)); graphOptions.putValue(Action.SMALL_ICON, GUIPrism.getIconFromImage("smallOptions.png")); graphOptions.putValue(Action.LONG_DESCRIPTION, "Displays the options dialog for the graph."); zoomIn = new AbstractAction() { public void actionPerformed(ActionEvent e) { JPanel mgm = models.get(theTabs.getSelectedIndex()); if (mgm instanceof ChartPanel) ((ChartPanel) mgm).zoomInBoth(-1, -1); else if (mgm instanceof Graph3D) { double rho = ((Graph3D) mgm).getChart3DPanel().getViewPoint().getRho(); ((Graph3D) mgm).getChart3DPanel().getViewPoint().setRho(rho - 5); ((Graph3D) mgm).getChart3DPanel().repaint(); } } }; zoomIn.putValue(Action.NAME, "In"); zoomIn.putValue(Action.MNEMONIC_KEY, new Integer(KeyEvent.VK_I)); zoomIn.putValue(Action.SMALL_ICON, GUIPrism.getIconFromImage("smallPlayerFwd.png")); zoomIn.putValue(Action.LONG_DESCRIPTION, "Zoom in on the graph."); zoomOut = new AbstractAction() { public void actionPerformed(ActionEvent e) { JPanel mgm = models.get(theTabs.getSelectedIndex()); if (mgm instanceof ChartPanel) ((ChartPanel) mgm).zoomOutBoth(-1, -1); else if (mgm instanceof Graph3D) { double rho = ((Graph3D) mgm).getChart3DPanel().getViewPoint().getRho(); ((Graph3D) mgm).getChart3DPanel().getViewPoint().setRho(rho + 5); ((Graph3D) mgm).getChart3DPanel().repaint(); } } }; zoomOut.putValue(Action.NAME, "Out"); zoomOut.putValue(Action.MNEMONIC_KEY, new Integer(KeyEvent.VK_O)); zoomOut.putValue(Action.SMALL_ICON, GUIPrism.getIconFromImage("smallPlayerRew.png")); zoomOut.putValue(Action.LONG_DESCRIPTION, "Zoom out of the graph."); zoomDefault = new AbstractAction() { public void actionPerformed(ActionEvent e) { JPanel mgm = models.get(theTabs.getSelectedIndex()); if (mgm instanceof ChartPanel) ((ChartPanel) mgm).restoreAutoBounds(); else if (mgm instanceof Graph3D) { ((Graph3D) mgm).getChart3DPanel().zoomToFit(); ((Graph3D) mgm).getChart3DPanel().getDrawable() .setViewPoint(new ViewPoint3D(-Math.PI / 2, Math.PI * 1.124, 70.0, 0.0)); ((Graph3D) mgm).getChart3DPanel().repaint(); } } }; zoomDefault.putValue(Action.NAME, "Default"); zoomDefault.putValue(Action.MNEMONIC_KEY, new Integer(KeyEvent.VK_D)); zoomDefault.putValue(Action.SMALL_ICON, GUIPrism.getIconFromImage("smallPlayerStart.png")); zoomDefault.putValue(Action.LONG_DESCRIPTION, "Set the default zoom for the graph."); importXML = new AbstractAction() { public void actionPerformed(ActionEvent e) { if (plug.showOpenFileDialog(graFilter) != JFileChooser.APPROVE_OPTION) return; try { Graph mgm = Graph.load(plug.getChooserFile()); addGraph(mgm); } catch (GraphException ex) { plug.error("Could not import PRISM graph file:\n" + ex.getMessage()); } } }; importXML.putValue(Action.NAME, "PRISM graph (*.gra)"); importXML.putValue(Action.MNEMONIC_KEY, new Integer(KeyEvent.VK_I)); importXML.putValue(Action.SMALL_ICON, GUIPrism.getIconFromImage("smallFileGraph.png")); importXML.putValue(Action.LONG_DESCRIPTION, "Imports a saved PRISM graph from a file."); addFunction = new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { plotNewFunction(); } }; addFunction.putValue(Action.NAME, "Plot function"); addFunction.putValue(Action.MNEMONIC_KEY, new Integer(KeyEvent.VK_P)); addFunction.putValue(Action.SMALL_ICON, GUIPrism.getIconFromImage("smallFunction.png")); addFunction.putValue(Action.LONG_DESCRIPTION, "Plots a new specified function on the current graph"); exportXML = new AbstractAction() { public void actionPerformed(ActionEvent e) { if (plug.showSaveFileDialog(graFilter) != JFileChooser.APPROVE_OPTION) return; Graph mgm = (Graph) models.get(theTabs.getSelectedIndex()); try { mgm.save(plug.getChooserFile()); } catch (PrismException ex) { plug.error("Could not export PRISM graph file:\n" + ex.getMessage()); } } }; exportXML.putValue(Action.NAME, "PRISM graph (*.gra)"); exportXML.putValue(Action.MNEMONIC_KEY, new Integer(KeyEvent.VK_X)); exportXML.putValue(Action.SMALL_ICON, GUIPrism.getIconFromImage("smallFileGraph.png")); exportXML.putValue(Action.LONG_DESCRIPTION, "Export graph as a PRISM graph file."); exportImageJPG = new AbstractAction() { public void actionPerformed(ActionEvent e) { JPanel model = getModel(theTabs.getSelectedIndex()); GUIImageExportDialog imageDialog = new GUIImageExportDialog(plug.getGUI(), model, GUIImageExportDialog.JPEG); saveImage(imageDialog); } }; exportImageJPG.putValue(Action.NAME, "JPEG Interchange Format (*.jpg, *.jpeg)"); exportImageJPG.putValue(Action.MNEMONIC_KEY, new Integer(KeyEvent.VK_J)); exportImageJPG.putValue(Action.SMALL_ICON, GUIPrism.getIconFromImage("smallFileImage.png")); exportImageJPG.putValue(Action.LONG_DESCRIPTION, "Export graph as a JPEG file."); exportImagePNG = new AbstractAction() { public void actionPerformed(ActionEvent e) { JPanel model = getModel(theTabs.getSelectedIndex()); GUIImageExportDialog imageDialog = new GUIImageExportDialog(plug.getGUI(), model, GUIImageExportDialog.PNG); saveImage(imageDialog); } }; exportImagePNG.putValue(Action.NAME, "Portable Network Graphics (*.png)"); exportImagePNG.putValue(Action.MNEMONIC_KEY, new Integer(KeyEvent.VK_P)); exportImagePNG.putValue(Action.SMALL_ICON, GUIPrism.getIconFromImage("smallFileImage.png")); exportImagePNG.putValue(Action.LONG_DESCRIPTION, "Export graph as a Portable Network Graphics file."); exportPDF = new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { if (plug.showSaveFileDialog(pdfFilter) != JFileChooser.APPROVE_OPTION) return; JPanel mgm = models.get(theTabs.getSelectedIndex()); if (mgm instanceof ChartPanel) Graph.exportToPDF(plug.getChooserFile(), ((ChartPanel) mgm).getChart()); else if (mgm instanceof Graph3D) { Graph3D.exportToPDF(plug.getChooserFile(), ((Graph3D) mgm).getChart3DPanel()); } } }; exportPDF.putValue(Action.NAME, "Portable document format (*.pdf)"); exportPDF.putValue(Action.MNEMONIC_KEY, new Integer(KeyEvent.VK_P)); exportPDF.putValue(Action.SMALL_ICON, GUIPrism.getIconFromImage("smallFilePdf.png")); exportPDF.putValue(Action.LONG_DESCRIPTION, "Export the graph as a Portable document format file."); exportImageEPS = new AbstractAction() { public void actionPerformed(ActionEvent e) { JPanel model = getModel(theTabs.getSelectedIndex()); if (model instanceof ChartPanel) { GUIImageExportDialog imageDialog = new GUIImageExportDialog(plug.getGUI(), (ChartPanel) model, GUIImageExportDialog.EPS); saveImage(imageDialog); } } }; exportImageEPS.putValue(Action.NAME, "Encapsulated PostScript (*.eps)"); exportImageEPS.putValue(Action.MNEMONIC_KEY, new Integer(KeyEvent.VK_E)); exportImageEPS.putValue(Action.SMALL_ICON, GUIPrism.getIconFromImage("smallFilePdf.png")); exportImageEPS.putValue(Action.LONG_DESCRIPTION, "Export graph as an Encapsulated PostScript file."); exportMatlab = new AbstractAction() { public void actionPerformed(ActionEvent e) { if (plug.showSaveFileDialog(matlabFilter) != JFileChooser.APPROVE_OPTION) return; JPanel mgm = models.get(theTabs.getSelectedIndex()); if (mgm instanceof Graph) { try { ((Graph) mgm).exportToMatlab(plug.getChooserFile()); } catch (IOException ex) { plug.error("Could not export Matlab file:\n" + ex.getMessage()); } } else if (mgm instanceof Graph3D) { try { ((Graph3D) mgm).exportToMatlab(plug.getChooserFile()); } catch (IOException e1) { plug.error("Could not export Matlab file:\n" + e1.getMessage()); e1.printStackTrace(); } } } }; exportMatlab.putValue(Action.NAME, "Matlab file (*.m)"); exportMatlab.putValue(Action.MNEMONIC_KEY, new Integer(KeyEvent.VK_M)); exportMatlab.putValue(Action.SMALL_ICON, GUIPrism.getIconFromImage("smallFileMatlab.png")); exportMatlab.putValue(Action.LONG_DESCRIPTION, "Export graph as a Matlab file."); exportGnuplot = new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { if (plug.showSaveFileDialog(gnuplotFilter) != JFileChooser.APPROVE_OPTION) return; JPanel mgm = models.get(theTabs.getSelectedIndex()); if (mgm instanceof ChartPanel) { try { if (mgm instanceof Graph && !(mgm instanceof ParametricGraph)) { ((Graph) mgm).exportToGnuplot(plug.getChooserFile()); } else if (mgm instanceof ParametricGraph) { ((ParametricGraph) mgm).exportToGnuplot(plug.getChooserFile()); } else if (mgm instanceof Histogram) { ((Histogram) mgm).exportToGnuplot(plug.getChooserFile()); } } catch (IOException ex) { plug.error("Could not export Gnuplot file:\n" + ex.getMessage()); } } else if (mgm instanceof Graph3D) { try { ((Graph3D) mgm).exportToGnuplot(plug.getChooserFile()); } catch (IOException ex) { plug.error("Could not export Gnuplot file:\n" + ex.getMessage()); ex.printStackTrace(); } } } }; exportGnuplot.putValue(Action.NAME, "GNU Plot file(*.gnuplot)"); exportGnuplot.putValue(Action.MNEMONIC_KEY, new Integer(KeyEvent.VK_G)); exportGnuplot.putValue(Action.SMALL_ICON, GUIPrism.getIconFromImage("smallgnuplot.png")); exportGnuplot.putValue(Action.LONG_DESCRIPTION, "Export graph as a GNU plot file."); printGraph = new AbstractAction() { public void actionPerformed(ActionEvent e) { JPanel graph = models.get(theTabs.getSelectedIndex()); if (graph instanceof ChartPanel) { if (graph instanceof Graph) { if (!((Graph) graph).getDisplaySettings().getBackgroundColor().equals(Color.white)) { if (plug.questionYesNo( "Your graph has a coloured background, this background will show up on the \n" + "printout. Would you like to make the current background colour white?") == 0) { ((Graph) graph).getDisplaySettings().setBackgroundColor(Color.white); } } } else if (graph instanceof Histogram) { if (!((Histogram) graph).getDisplaySettings().getBackgroundColor().equals(Color.white)) { if (plug.questionYesNo( "Your graph has a coloured background, this background will show up on the \n" + "printout. Would you like to make the current background colour white?") == 0) { ((Histogram) graph).getDisplaySettings().setBackgroundColor(Color.white); } } } ((ChartPanel) graph).createChartPrintJob(); } if (graph instanceof Graph3D) { ((Graph3D) graph).createPrintJob(); } } }; printGraph.putValue(Action.NAME, "Print graph"); printGraph.putValue(Action.MNEMONIC_KEY, new Integer(KeyEvent.VK_P)); printGraph.putValue(Action.SMALL_ICON, GUIPrism.getIconFromImage("smallPrint.png")); printGraph.putValue(Action.LONG_DESCRIPTION, "Print the graph to a printer or file"); deleteGraph = new AbstractAction() { public void actionPerformed(ActionEvent e) { JPanel graph = models.get(theTabs.getSelectedIndex()); models.remove(theTabs.getSelectedIndex()); options.remove(theTabs.getSelectedIndex()); theTabs.remove(graph); } }; deleteGraph.putValue(Action.NAME, "Delete graph"); deleteGraph.putValue(Action.MNEMONIC_KEY, new Integer(KeyEvent.VK_D)); deleteGraph.putValue(Action.SMALL_ICON, GUIPrism.getIconFromImage("smallDelete.png")); deleteGraph.putValue(Action.LONG_DESCRIPTION, "Deletes the graph."); zoomMenu = new JMenu("Zoom"); zoomMenu.setMnemonic('Z'); zoomMenu.setIcon(GUIPrism.getIconFromImage("smallView.png")); zoomMenu.add(zoomIn); zoomMenu.add(zoomOut); zoomMenu.add(zoomDefault); exportMenu = new JMenu("Export graph"); exportMenu.setMnemonic('E'); exportMenu.setIcon(GUIPrism.getIconFromImage("smallExport.png")); exportMenu.add(exportXML); exportMenu.add(exportImagePNG); exportMenu.add(exportPDF); exportMenu.add(exportImageEPS); exportMenu.add(exportImageJPG); exportMenu.add(exportMatlab); exportMenu.add(exportGnuplot); importMenu = new JMenu("Import graph"); importMenu.setMnemonic('I'); importMenu.setIcon(GUIPrism.getIconFromImage("smallImport.png")); importMenu.add(importXML); graphMenu.add(graphOptions); graphMenu.add(zoomMenu); graphMenu.addSeparator(); graphMenu.add(printGraph); graphMenu.add(deleteGraph); graphMenu.addSeparator(); graphMenu.add(exportMenu); graphMenu.add(importMenu); graphMenu.add(addFunction); /* Tab context menu */ backMenu.add(importXML); }
From source file:org.eurocarbdb.application.glycoworkbench.plugin.AnnotationReportApplet.java
private void updateActions() { theActionManager.get("undo").setEnabled(theCanvas.getDocument().getUndoManager().canUndo()); theActionManager.get("redo").setEnabled(theCanvas.getDocument().getUndoManager().canRedo()); theActionManager.get("cut").setEnabled(theCanvas.hasSelection()); theActionManager.get("copy").setEnabled(theCanvas.hasSelection()); theActionManager.get("delete").setEnabled(theCanvas.hasSelection()); theActionManager.get("enlarge").setEnabled(theCanvas.hasSelection()); theActionManager.get("resetsize").setEnabled(theCanvas.hasSelection()); theActionManager.get("shrink").setEnabled(theCanvas.hasSelection()); theActionManager.get("group").setEnabled(theCanvas.canGroupSelections()); theActionManager.get("orientation").putValue(Action.SMALL_ICON, getOrientationIcon()); }
From source file:com.anrisoftware.prefdialog.miscswing.actions.AbstractResourcesAction.java
/** * Returns the small icon of the action. * * @return the {@link ImageIcon} icon or {@code null} if not set. * @see Action#SMALL_ICON//from ww w . ja v a 2s.c o m * @since 3.1 */ public final ImageIcon getSmallIcon() { return (ImageIcon) getValue(Action.SMALL_ICON); }
From source file:captureplugin.CapturePlugin.java
public ActionMenu getButtonAction() { AbstractAction action = new AbstractAction() { public void actionPerformed(ActionEvent evt) { showDialog();//from ww w. j av a2s. co m } }; action.putValue(Action.NAME, mLocalizer.msg("CapturePlugin", "Capture Plugin")); action.putValue(Action.SMALL_ICON, createImageIcon("mimetypes", "video-x-generic", 16)); action.putValue(BIG_ICON, createImageIcon("mimetypes", "video-x-generic", 22)); return new ActionMenu(action); }
From source file:idontwant2see.IDontWant2See.java
public ActionMenu getContextMenuActions(final Program p) { if (p == null) { return null; }/*from www .j a v a 2s. com*/ // check if this program is already hidden final int index = getSearchTextIndexForProgram(p); // return menu to hide the program if (index == -1 || p.equals(getPluginManager().getExampleProgram())) { AbstractAction actionDontWant = getActionDontWantToSee(p); if (mSettings.isSimpleMenu() && !mCtrlPressed) { final Matcher matcher = PATTERN_TITLE_PART.matcher(p.getTitle()); if (matcher.matches()) { actionDontWant = getActionInputTitle(p, matcher.group(2)); } actionDontWant.putValue(Action.NAME, mLocalizer.msg("name", "I don't want to see!")); actionDontWant.putValue(Action.SMALL_ICON, createImageIcon("apps", "idontwant2see", 16)); return new ActionMenu(actionDontWant); } else { final AbstractAction actionInput = getActionInputTitle(p, null); final ContextMenuAction baseAction = new ContextMenuAction( mLocalizer.msg("name", "I don't want to see!"), createImageIcon("apps", "idontwant2see", 16)); return new ActionMenu(baseAction, new Action[] { actionDontWant, actionInput }); } } // return menu to show the program return new ActionMenu(getActionShowAgain(p)); }