List of usage examples for javax.swing JMenuItem setToolTipText
@BeanProperty(bound = false, preferred = true, description = "The text to display in a tool tip.") public void setToolTipText(String text)
From source file:br.org.acessobrasil.ases.ferramentas_de_reparo.vista.navegacao_cego.PainelSimuladorNavegacao.java
/** * Cria o menu editar do Frame Principal * /*from ww w . j a v a 2 s .com*/ * @param menu */ private JMenu criaMenuEditar() { JMenu menu = new JMenu(GERAL.EDITAR); menu.setBackground(parentFrame.corDefault); menu.setMnemonic('E'); menu.setMnemonic(KeyEvent.VK_E); JMenuItem btnContraste = new JMenuItem(GERAL.BTN_ALTERAR_CONTRASTE); btnContraste.addActionListener(this); btnContraste.setActionCommand("Contraste"); // btnAumenta.setMnemonic('F'); // btnAumenta.setMnemonic(KeyEvent.VK_F); // btnAumenta.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_ADD, // ActionEvent.CTRL_MASK)); btnContraste.setToolTipText(GERAL.ALTERAR_CONTRASTE); btnContraste.getAccessibleContext().setAccessibleDescription(GERAL.ALTERAR_CONTRASTE); menu.add(btnContraste); JMenuItem btnAumenta = new JMenuItem(GERAL.AUMENTA_FONTE); btnAumenta.addActionListener(this); btnAumenta.setActionCommand("AumentaFonte"); // btnAumenta.setMnemonic('F'); // btnAumenta.setMnemonic(KeyEvent.VK_F); btnAumenta.setAccelerator( javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_ADD, ActionEvent.CTRL_MASK)); btnAumenta.setToolTipText(GERAL.DICA_AUMENTA_FONTE); btnAumenta.getAccessibleContext().setAccessibleDescription(GERAL.DICA_AUMENTA_FONTE); menu.add(btnAumenta); JMenuItem btnDiminui = new JMenuItem(GERAL.DIMINUI_FONTE); btnDiminui.addActionListener(this); btnDiminui.setActionCommand("DiminuiFonte"); // btnDiminui.setMnemonic('F'); // btnDiminui.setMnemonic(KeyEvent.VK_F); btnDiminui.setAccelerator( javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_SUBTRACT, ActionEvent.CTRL_MASK)); btnDiminui.setToolTipText(GERAL.DICA_DIMINUI_FONTE); btnDiminui.getAccessibleContext().setAccessibleDescription(GERAL.DICA_DIMINUI_FONTE); menu.add(btnDiminui); JMenuItem btnSelecionarTudo = new JMenuItem(GERAL.SELECIONAR_TUDO); btnSelecionarTudo.addActionListener(this); btnSelecionarTudo.setActionCommand("SelecionarTudo"); btnSelecionarTudo.setMnemonic('T'); btnSelecionarTudo.setMnemonic(KeyEvent.VK_T); btnSelecionarTudo.setAccelerator( javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_T, ActionEvent.CTRL_MASK)); btnSelecionarTudo.setToolTipText(GERAL.DICA_SELECIONAR_TUDO); btnSelecionarTudo.getAccessibleContext().setAccessibleDescription(GERAL.DICA_SELECIONAR_TUDO); menu.add(btnSelecionarTudo); menu.add(new JSeparator()); /* * JMenuItem btnProcurar = new JMenuItem(GERAL.PROCURAR); * btnProcurar.addActionListener(this); * btnProcurar.setActionCommand("Procurar"); * btnProcurar.setMnemonic('P'); btnProcurar.setMnemonic(KeyEvent.VK_P); * btnProcurar.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_F, * ActionEvent.CTRL_MASK)); * btnProcurar.setToolTipText(GERAL.DICA_PROCURAR); * btnProcurar.getAccessibleContext().setAccessibleDescription(GERAL.DICA_PROCURAR); * menu.add(btnProcurar); * * JMenuItem btnSelecionarTudo = new JMenuItem(GERAL.SELECIONAR_TUDO); * btnSelecionarTudo.addActionListener(this); * btnSelecionarTudo.setActionCommand("SelecionarTudo"); * btnSelecionarTudo.setMnemonic('T'); * btnSelecionarTudo.setMnemonic(KeyEvent.VK_T); * btnSelecionarTudo.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_T, * ActionEvent.CTRL_MASK)); * btnSelecionarTudo.setToolTipText(GERAL.DICA_SELECIONAR_TUDO); * btnSelecionarTudo.getAccessibleContext().setAccessibleDescription(GERAL.DICA_SELECIONAR_TUDO); * menu.add(btnSelecionarTudo); * * JMenuItem btnDesfazer = new JMenuItem(GERAL.DESFAZER); * btnDesfazer.addActionListener(this); * btnDesfazer.setActionCommand("Desfazer"); * btnDesfazer.setMnemonic('z'); btnDesfazer.setMnemonic(KeyEvent.VK_Z); * btnDesfazer.getAccessibleContext().setAccessibleDescription(GERAL.DICA_DESFAZER); * btnDesfazer.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_Z, * ActionEvent.CTRL_MASK)); menu.add(btnDesfazer); * menu.setEnabled(true); */ return menu; }
From source file:com.igormaznitsa.sciareto.ui.MainFrame.java
public MainFrame(@Nonnull @MustNotContainNull final String... args) { super();/*from w w w . ja v a2 s. c o m*/ initComponents(); this.stackPanel = new JPanel(); this.stackPanel.setFocusable(false); this.stackPanel.setOpaque(false); this.stackPanel.setBorder(BorderFactory.createEmptyBorder(32, 32, 16, 32)); this.stackPanel.setLayout(new BoxLayout(this.stackPanel, BoxLayout.Y_AXIS)); final JPanel glassPanel = (JPanel) this.getGlassPane(); glassPanel.setOpaque(false); this.setGlassPane(glassPanel); glassPanel.setLayout(new BorderLayout(8, 8)); glassPanel.add(Box.createGlue(), BorderLayout.CENTER); final JPanel ppanel = new JPanel(new BorderLayout(0, 0)); ppanel.setFocusable(false); ppanel.setOpaque(false); ppanel.setCursor(null); ppanel.add(this.stackPanel, BorderLayout.SOUTH); glassPanel.add(ppanel, BorderLayout.EAST); this.stackPanel.add(Box.createGlue()); glassPanel.setVisible(false); this.setTitle("Scia Reto"); setIconImage(UiUtils.loadImage("logo256x256.png")); this.stateless = args.length > 0; final MainFrame theInstance = this; this.addWindowListener(new WindowAdapter() { @Override public void windowClosing(@Nonnull final WindowEvent e) { if (doClosing()) { dispose(); } } }); this.tabPane = new EditorTabPane(this); this.explorerTree = new ExplorerTree(this); final JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT); splitPane.setOneTouchExpandable(true); splitPane.setDividerLocation(250); splitPane.setResizeWeight(0.0d); splitPane.setLeftComponent(this.explorerTree); splitPane.setRightComponent(this.tabPane); add(splitPane, BorderLayout.CENTER); this.menuOpenRecentProject.addMenuListener(new MenuListener() { @Override public void menuSelected(MenuEvent e) { final File[] lastOpenedProjects = FileHistoryManager.getInstance().getLastOpenedProjects(); if (lastOpenedProjects.length > 0) { for (final File folder : lastOpenedProjects) { final JMenuItem item = new JMenuItem(folder.getName()); item.setToolTipText(folder.getAbsolutePath()); item.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { openProject(folder, false); } }); menuOpenRecentProject.add(item); } } } @Override public void menuDeselected(MenuEvent e) { menuOpenRecentProject.removeAll(); } @Override public void menuCanceled(MenuEvent e) { } }); this.menuOpenRecentFile.addMenuListener(new MenuListener() { @Override public void menuSelected(MenuEvent e) { final File[] lastOpenedFiles = FileHistoryManager.getInstance().getLastOpenedFiles(); if (lastOpenedFiles.length > 0) { for (final File file : lastOpenedFiles) { final JMenuItem item = new JMenuItem(file.getName()); item.setToolTipText(file.getAbsolutePath()); item.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { openFileAsTab(file); } }); menuOpenRecentFile.add(item); } } } @Override public void menuDeselected(MenuEvent e) { menuOpenRecentFile.removeAll(); } @Override public void menuCanceled(MenuEvent e) { } }); if (!this.stateless) { restoreState(); } else { boolean openedProject = false; for (final String filePath : args) { final File file = new File(filePath); if (file.isDirectory()) { openedProject = true; openProject(file, true); } else if (file.isFile()) { openFileAsTab(file); } } if (!openedProject) { //TODO try to hide project panel! } } final LookAndFeel current = UIManager.getLookAndFeel(); final ButtonGroup lfGroup = new ButtonGroup(); final String currentLFClassName = current.getClass().getName(); for (final UIManager.LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) { final JRadioButtonMenuItem menuItem = new JRadioButtonMenuItem(info.getName()); lfGroup.add(menuItem); if (currentLFClassName.equals(info.getClassName())) { menuItem.setSelected(true); } menuItem.addActionListener(new ActionListener() { @Override public void actionPerformed(@Nonnull final ActionEvent e) { try { UIManager.setLookAndFeel(info.getClassName()); SwingUtilities.updateComponentTreeUI(theInstance); PreferencesManager.getInstance().getPreferences().put(Main.PROPERTY_LOOKANDFEEL, info.getClassName()); PreferencesManager.getInstance().flush(); } catch (Exception ex) { LOGGER.error("Can't change LF", ex); } } }); this.menuLookAndFeel.add(menuItem); } }
From source file:ee.ioc.cs.vsle.editor.Editor.java
/** * /*from w ww. j a v a 2 s. c om*/ */ private void makeToolsMenu(JMenuBar _menuBar) { JMenu menu = new JMenu(Menu.MENU_TOOLS); menu.setMnemonic(KeyEvent.VK_T); _menuBar.add(menu); JMenuItem menuItem = new JMenuItem(Menu.EXPERT_TABLE); menuItem.addActionListener(getActionListener()); menu.add(menuItem); if (RuntimeProperties.isFromWebstart()) { menuItem = new JMenuItem(Menu.ICON_EDITOR); menuItem.addActionListener(getActionListener()); menu.add(menuItem); } menuItem = new JCheckBoxMenuItem(Menu.SHOW_ALGORITHM, RuntimeProperties.isShowAlgorithm()); menuItem.setToolTipText("If checked, after planning a window with the synthesized algorithm will be shown"); menuItem.addActionListener(getActionListener()); menu.add(menuItem); menuItem = new JMenuItem(Menu.VIEW_THREADS); menuItem.addActionListener(getActionListener()); menu.add(menuItem); menuItem = new JMenuItem(Menu.JAVA_CONSOLE); menuItem.addActionListener(getActionListener()); menu.add(menuItem); }
From source file:SciTK.Plot.java
/** * Load the initial UI/*from w ww. j av a2 s .com*/ */ protected final void initUI() { setLayout(new BoxLayout(getContentPane(), BoxLayout.Y_AXIS)); // create a ChartPanel, and make it default to 1/4 of screen size: chart_panel = new ChartPanel(chart); chart_panel.setPreferredSize(new Dimension(def_width, def_height)); //add the chart to the window: getContentPane().add(chart_panel); // create a menu bar: menubar = new JMenuBar(); // --------------------------------------------------------- // First dropdown menu: "File" // --------------------------------------------------------- file = new JMenu("File"); file.setMnemonic(KeyEvent.VK_F); // Set up a save dialog option under the file menu: JMenuItem menu_file_save; ImageIcon menu_file_save_icon = null; try { menu_file_save_icon = new ImageIcon(getClass().getResource("/SciTK/resources/document-save-5.png")); menu_file_save = new JMenuItem("Save", menu_file_save_icon); } catch (Exception e) { menu_file_save = new JMenuItem("Save"); } menu_file_save.setMnemonic(KeyEvent.VK_S); menu_file_save.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_S, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); menu_file_save.setToolTipText("Save an image"); menu_file_save.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { saveImage(); } }); file.add(menu_file_save); // Set up a save SVG dialog option under the file menu: JMenuItem menu_file_save_svg; try { menu_file_save_svg = new JMenuItem("Save VG", menu_file_save_icon); } catch (Exception e) { menu_file_save_svg = new JMenuItem("Save VG"); } menu_file_save_svg.setToolTipText("Save as vector graphics (SVG,PS,EPS)"); menu_file_save_svg.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { saveVectorGraphics(); } }); file.add(menu_file_save_svg); // Set up a save data dialog option under the file menu: JMenuItem menu_file_save_data; try { menu_file_save_data = new JMenuItem("Save data", menu_file_save_icon); } catch (Exception e) { menu_file_save_data = new JMenuItem("Save data"); } menu_file_save_data.setToolTipText("Save raw data to file"); menu_file_save_data.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { saveData(); } }); file.add(menu_file_save_data); // Set up a save data dialog option under the file menu: JMenuItem menu_file_print; try { ImageIcon menu_file_print_icon = new ImageIcon( getClass().getResource("/SciTK/resources/document-print-5.png")); menu_file_print = new JMenuItem("Print", menu_file_print_icon); } catch (Exception e) { menu_file_print = new JMenuItem("Print"); } menu_file_print.setToolTipText("Print image of chart"); menu_file_print.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { printPlot(); } }); file.add(menu_file_print); // menu item for exiting JMenuItem menu_file_exit; try { ImageIcon menu_file_exit_icon = new ImageIcon( getClass().getResource("/SciTK/resources/application-exit.png")); menu_file_exit = new JMenuItem("Exit", menu_file_exit_icon); } catch (Exception e) { menu_file_exit = new JMenuItem("Exit"); } menu_file_exit.setMnemonic(KeyEvent.VK_X); menu_file_exit.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_X, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); menu_file_exit.setToolTipText("Exit application"); menu_file_exit.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { dispose(); } }); file.add(menu_file_exit); // --------------------------------------------------------- // Second dropdown menu: "Edit" // --------------------------------------------------------- edit = new JMenu("Edit"); edit.setMnemonic(KeyEvent.VK_E); // copy to clipboard JMenuItem menu_edit_copy_image; ImageIcon menu_edit_copy_icon = null; try { menu_edit_copy_icon = new ImageIcon(getClass().getResource("/SciTK/resources/edit-copy-7.png")); menu_edit_copy_image = new JMenuItem("Copy", menu_edit_copy_icon); } catch (Exception e) { menu_edit_copy_image = new JMenuItem("Copy"); } menu_edit_copy_image.setMnemonic(KeyEvent.VK_C); menu_edit_copy_image.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_C, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); menu_edit_copy_image.setToolTipText("Copy image to clipboard"); menu_edit_copy_image.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { copyImage(); } }); edit.add(menu_edit_copy_image); // copy data to clipboard JMenuItem menu_edit_copy_data; try { menu_edit_copy_data = new JMenuItem("Copy data", menu_edit_copy_icon); } catch (Exception e) { menu_edit_copy_data = new JMenuItem("Copy data"); } menu_edit_copy_data.setToolTipText("Copy data to clipboard"); menu_edit_copy_data.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { copyData(); } }); edit.add(menu_edit_copy_data); // set background color JMenuItem menu_edit_BackgroundColor; ImageIcon menu_edit_Color_icon = null; try { menu_edit_Color_icon = new ImageIcon(getClass().getResource("/SciTK/resources/color-wheel.png")); menu_edit_BackgroundColor = new JMenuItem("Background Color", menu_edit_Color_icon); } catch (Exception e) { menu_edit_BackgroundColor = new JMenuItem("Background Color"); } menu_edit_BackgroundColor.setToolTipText("Select background color"); menu_edit_BackgroundColor.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { Color bgColor = plotColorChooser("Choose background color", (Color) chart.getBackgroundPaint()); setBackgroundColor(bgColor); } }); edit.add(menu_edit_BackgroundColor); // set plot color JMenuItem menu_edit_PlotColor; try { menu_edit_PlotColor = new JMenuItem("Window Color", menu_edit_Color_icon); } catch (Exception e) { menu_edit_PlotColor = new JMenuItem("Window Color"); } menu_edit_PlotColor.setToolTipText("Select plot window color"); menu_edit_PlotColor.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { Color plotColor = plotColorChooser("Choose plot color", (Color) chart.getPlot().getBackgroundPaint()); setWindowBackground(plotColor); } }); edit.add(menu_edit_PlotColor); // set gridline color JMenuItem menu_edit_GridlineColor; try { menu_edit_GridlineColor = new JMenuItem("Gridline Color", menu_edit_Color_icon); } catch (Exception e) { menu_edit_GridlineColor = new JMenuItem("Gridline Color"); } menu_edit_GridlineColor.setToolTipText("Select grid color"); menu_edit_GridlineColor.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { Color gridColor = plotColorChooser("Choose grid color", (Color) chart.getPlot().getBackgroundPaint()); setGridlineColor(gridColor); } }); edit.add(menu_edit_GridlineColor); // edit chart preferences JMenuItem menu_edit_preferences; try { ImageIcon menu_edit_preferences_icon = new ImageIcon( getClass().getResource("/SciTK/resources/preferences-desktop-3.png")); menu_edit_preferences = new JMenuItem("Preferences", menu_edit_preferences_icon); } catch (Exception e) { menu_edit_preferences = new JMenuItem("Preferences"); } menu_edit_preferences.setToolTipText("Edit chart preferences"); menu_edit_preferences.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { chart_panel.doEditChartProperties(); } }); edit.add(menu_edit_preferences); // --------------------------------------------------------- // Third dropdown menu: "Plot" // --------------------------------------------------------- plot = new JMenu("Plot"); plot.setMnemonic(KeyEvent.VK_P); // Options to set log axes JCheckBoxMenuItem menu_plot_ylog = new JCheckBoxMenuItem("Log y axis"); menu_plot_ylog.setToolTipText("Set y axis to logarithmic"); menu_plot_ylog.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { AbstractButton aButton = (AbstractButton) event.getSource(); boolean selected = aButton.getModel().isSelected(); setRangeAxisLog(selected); } }); plot.add(menu_plot_ylog); JCheckBoxMenuItem menu_plot_xlog = new JCheckBoxMenuItem("Log x axis"); menu_plot_xlog.setToolTipText("Set x axis to logarithmic"); menu_plot_xlog.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { AbstractButton aButton = (AbstractButton) event.getSource(); boolean selected = aButton.getModel().isSelected(); setDomainAxisLog(selected); } }); plot.add(menu_plot_xlog); // grid line display JCheckBoxMenuItem menu_plot_grid = new JCheckBoxMenuItem("Grid lines"); menu_plot_grid.setToolTipText("Show plot grid lines?"); menu_plot_grid.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { AbstractButton aButton = (AbstractButton) event.getSource(); boolean selected = aButton.getModel().isSelected(); setGridlineVisible(selected); } }); // set appropirate checkbox state: menu_plot_grid.setState(chart.getXYPlot().isDomainGridlinesVisible()); plot.add(menu_plot_grid); // control for displaying plot legend JCheckBoxMenuItem menu_plot_legend = new JCheckBoxMenuItem("Legend"); menu_plot_legend.setToolTipText("Show plot legend?"); menu_plot_legend.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { AbstractButton aButton = (AbstractButton) event.getSource(); boolean selected = aButton.getModel().isSelected(); setLegend(selected); } }); // set appropirate checkbox state: menu_plot_legend.setState((chart.getLegend() instanceof LegendTitle)); plot.add(menu_plot_legend); // --------------------------------------------------------- // General UI // --------------------------------------------------------- // Add menus to the menu bar: menubar.add(file); menubar.add(edit); menubar.add(plot); // Set menubar as this JFrame's menu setJMenuBar(menubar); // set default plot colors: chart.setBackgroundPaint(new Color(255, 255, 255, 0)); chart.getPlot().setBackgroundPaint(new Color(255, 255, 255, 255)); setBackgroundAlpha(0.0f); setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); pack(); setTitle(window_title); setLocationRelativeTo(null); setVisible(true); }
From source file:br.org.acessobrasil.ases.ferramentas_de_reparo.vista.imagem.analise_geral.PanelAnaliseGeral.java
private JMenuBar criaMenuBar() { menuBar = new JMenuBar(); menuBar.setBackground(parentFrame.corDefault); JMenu menuArquivo = new JMenu(GERAL.ARQUIVO); menuArquivo.setMnemonic('A'); menuArquivo.setMnemonic(KeyEvent.VK_A); menuArquivo.setBackground(parentFrame.corDefault); JMenu avaliadores = new JMenu(); MenuSilvinha menuSilvinha = new MenuSilvinha(parentFrame, null); menuSilvinha.criaMenuAvaliadores(avaliadores); // menuArquivo.add(avaliadores); // menuArquivo.add(new JSeparator()); JMenuItem btnAbrir = new JMenuItem(GERAL.BTN_ABRIR); btnAbrir.addActionListener(this); btnAbrir.setActionCommand("Abrir"); btnAbrir.setMnemonic('A'); btnAbrir.setAccelerator(// w ww .j av a 2s.co m javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_O, ActionEvent.CTRL_MASK)); btnAbrir.setMnemonic(KeyEvent.VK_A); btnAbrir.setToolTipText(GERAL.DICA_ABRIR); btnAbrir.getAccessibleContext().setAccessibleDescription(GERAL.DICA_ABRIR); menuArquivo.add(btnAbrir); JMenuItem btnAbrirUrl = new JMenuItem(br.org.acessobrasil.silvinha2.mli.XHTML_Panel.BTN_ABRIR_URL); btnAbrirUrl.addActionListener(this); btnAbrirUrl.setActionCommand("AbrirURL"); btnAbrirUrl.setMnemonic('U'); btnAbrirUrl.setAccelerator( javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_U, ActionEvent.CTRL_MASK)); btnAbrirUrl.setMnemonic(KeyEvent.VK_U); btnAbrirUrl.setToolTipText(br.org.acessobrasil.silvinha2.mli.XHTML_Panel.DICA_ABRIR); btnAbrirUrl.getAccessibleContext() .setAccessibleDescription(br.org.acessobrasil.silvinha2.mli.XHTML_Panel.DICA_ABRIR); menuArquivo.add(btnAbrirUrl); btnSalvar = new JMenuItem(GERAL.BTN_SALVAR); btnSalvar.addActionListener(this); btnSalvar.setActionCommand("Salvar"); btnSalvar.setMnemonic('S'); btnSalvar.setAccelerator( javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S, ActionEvent.CTRL_MASK)); btnSalvar.setMnemonic(KeyEvent.VK_S); btnSalvar.getAccessibleContext().setAccessibleDescription(GERAL.SALVA_REAVALIA); menuArquivo.add(btnSalvar); JMenuItem btnSalvarAs = new JMenuItem(GERAL.BTN_SALVAR_COMO); btnSalvarAs.addActionListener(this); btnSalvarAs.setActionCommand("SaveAs"); btnSalvarAs.setMnemonic('c'); btnSalvarAs.setMnemonic(KeyEvent.VK_C); // btnSalvarAs.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_N, // ActionEvent.CTRL_MASK)); btnSalvarAs.setToolTipText(GERAL.DICA_SALVAR_COMO); btnSalvarAs.getAccessibleContext().setAccessibleDescription(GERAL.DICA_SALVAR_COMO); menuArquivo.add(btnSalvarAs); menuArquivo.add(new JSeparator()); JMenuItem btnFechar = new JMenuItem(GERAL.SAIR); btnFechar.addActionListener(this); btnFechar.setActionCommand("Sair"); btnFechar.setMnemonic('a'); btnFechar.setMnemonic(KeyEvent.VK_A); btnFechar.setToolTipText(GERAL.DICA_SAIR); btnFechar.getAccessibleContext().setAccessibleDescription(GERAL.DICA_SAIR); menuArquivo.add(btnFechar); menuBar.add(menuArquivo); menuBar.add(this.criaMenuEditar()); menuBar.add(avaliadores); JMenu menuSimuladores = new JMenu(); menuSilvinha.criaMenuSimuladores(menuSimuladores); menuBar.add(menuSimuladores); JMenu mnFerramenta = new JMenu(); menuSilvinha.criaMenuFerramentas(mnFerramenta); menuBar.add(mnFerramenta); JMenu menuAjuda = new JMenu(GERAL.AJUDA); menuSilvinha.criaMenuAjuda(menuAjuda); menuBar.add(menuAjuda); return menuBar; }
From source file:br.org.acessobrasil.ases.ferramentas_de_reparo.vista.imagem.analise_geral.PanelAnaliseGeral.java
/** * Cria o menu editar do Frame Principal * //ww w . ja va2 s. com * @param menu */ private JMenu criaMenuEditar() { JMenu menu = new JMenu(GERAL.EDITAR); menu.setBackground(parentFrame.corDefault); menu.setMnemonic('E'); menu.setMnemonic(KeyEvent.VK_E); JMenuItem btnContraste = new JMenuItem(GERAL.ALTERAR_CONTRASTE); btnContraste.addActionListener(this); btnContraste.setActionCommand("Contraste"); // btnAumenta.setMnemonic('F'); // btnAumenta.setMnemonic(KeyEvent.VK_F); // btnAumenta.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_ADD, // ActionEvent.CTRL_MASK)); btnContraste.setToolTipText(GERAL.DICA_CONTRASTE); btnContraste.getAccessibleContext().setAccessibleDescription(GERAL.DICA_CONTRASTE); menu.add(btnContraste); JMenuItem btnAumenta = new JMenuItem(GERAL.AUMENTA_FONTE); btnAumenta.addActionListener(this); btnAumenta.setActionCommand("AumentaFonte"); // btnAumenta.setMnemonic('F'); // btnAumenta.setMnemonic(KeyEvent.VK_F); btnAumenta.setAccelerator( javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_ADD, ActionEvent.CTRL_MASK)); btnAumenta.setToolTipText(GERAL.DICA_AUMENTA_FONTE); btnAumenta.getAccessibleContext().setAccessibleDescription(GERAL.DICA_AUMENTA_FONTE); menu.add(btnAumenta); JMenuItem btnDiminui = new JMenuItem(GERAL.DIMINUI_FONTE); btnDiminui.addActionListener(this); btnDiminui.setActionCommand("DiminuiFonte"); // btnDiminui.setMnemonic('F'); // btnDiminui.setMnemonic(KeyEvent.VK_F); btnDiminui.setAccelerator( javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_SUBTRACT, ActionEvent.CTRL_MASK)); btnDiminui.setToolTipText(GERAL.DICA_DIMINUI_FONTE); btnDiminui.getAccessibleContext().setAccessibleDescription(GERAL.DICA_DIMINUI_FONTE); menu.add(btnDiminui); menu.add(new JSeparator()); JMenuItem btnProcurar = new JMenuItem(GERAL.PROCURAR); btnProcurar.addActionListener(this); btnProcurar.setActionCommand("Procurar"); btnProcurar.setMnemonic('P'); btnProcurar.setMnemonic(KeyEvent.VK_P); btnProcurar.setAccelerator( javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_F, ActionEvent.CTRL_MASK)); btnProcurar.setToolTipText(GERAL.DICA_PROCURAR); btnProcurar.getAccessibleContext().setAccessibleDescription(GERAL.DICA_PROCURAR); menu.add(btnProcurar); JMenuItem btnSelecionarTudo = new JMenuItem(GERAL.SELECIONAR_TUDO); btnSelecionarTudo.addActionListener(this); btnSelecionarTudo.setActionCommand("SelecionarTudo"); btnSelecionarTudo.setMnemonic('T'); btnSelecionarTudo.setMnemonic(KeyEvent.VK_T); btnSelecionarTudo.setAccelerator( javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_T, ActionEvent.CTRL_MASK)); btnSelecionarTudo.setToolTipText(GERAL.DICA_SELECIONAR_TUDO); btnSelecionarTudo.getAccessibleContext().setAccessibleDescription(GERAL.DICA_SELECIONAR_TUDO); menu.add(btnSelecionarTudo); JMenuItem btnDesfazer = new JMenuItem(GERAL.DESFAZER); btnDesfazer.addActionListener(this); btnDesfazer.setActionCommand("Desfazer"); btnDesfazer.setMnemonic('z'); btnDesfazer.setMnemonic(KeyEvent.VK_Z); btnDesfazer.getAccessibleContext().setAccessibleDescription(GERAL.DICA_DESFAZER); btnDesfazer.setAccelerator( javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_Z, ActionEvent.CTRL_MASK)); menu.add(btnDesfazer); menu.setEnabled(true); return menu; }
From source file:com.igormaznitsa.jhexed.swing.editor.ui.MainForm.java
private void readAndParsePluginScript(final Reader reader) throws IOException { final DelegatingScript script = (DelegatingScript) this.groovyShell.parse(reader); script.setDelegate(this.dsl); final String name = (String) script.invokeMethod("getPluginName", new Object[] {}); final String description = (String) script.invokeMethod("getDescription", new Object[] {}); final JMenuItem menuItem = new JMenuItem(name); menuItem.setToolTipText(description); menuItem.addActionListener(new ActionListener() { @Override//from ww w .j a v a 2 s. c o m public void actionPerformed(ActionEvent e) { try { if (selectedLayer != null) { addedUndoStep(new HexFieldLayer[] { selectedLayer }); } script.invokeMethod("doWork", new Object[] { selectedToolType, selectedLayer }); } catch (Exception ex) { ex.printStackTrace(); JOptionPane.showMessageDialog(rootPane, "Error during execution", "Script error", JOptionPane.ERROR_MESSAGE); } finally { updateRedoUndoForCurrentLayer(); } hexMapPanel.repaint(); } }); menuPlugins.add(menuItem); }
From source file:biz.wolschon.finance.jgnucash.JGnucash.java
/** * This method initializes import-menu//from ww w . j av a 2 s. co m * with plugins. * * @return javax.swing.JMenu */ @SuppressWarnings("unchecked") protected JMenu getToolMenu() { if (toolMenu == null) { toolMenu = new JMenu(); toolMenu.setText("Tools"); toolMenu.setMnemonic('t'); //importMenu.setEnabled(false);// first we need to load a file PluginManager manager = getPluginManager(); // if we are configured for the plugin-api if (manager != null) { ExtensionPoint toolExtPoint = manager.getRegistry().getExtensionPoint(getPluginDescriptor().getId(), "Tool"); for (Iterator<Extension> it = toolExtPoint.getConnectedExtensions().iterator(); it.hasNext();) { Extension ext = it.next(); String pluginName = "unknown"; try { pluginName = ext.getParameter("name").valueAsString(); JMenuItem newMenuItem = new JMenuItem(); newMenuItem.putClientProperty("extension", ext); Parameter descrParam = ext.getParameter("description"); Parameter iconParam = ext.getParameter("icon"); URL iconUrl = null; if (iconParam != null) { try { iconUrl = getPluginManager() .getPluginClassLoader(ext.getDeclaringPluginDescriptor()) .getResource(iconParam.valueAsString()); if (iconUrl != null) { newMenuItem.setIcon(new ImageIcon(iconUrl)); } } catch (Exception e) { LOGGER.error("cannot load icon for Tool-Plugin '" + pluginName + "'", e); } } newMenuItem.setText(pluginName); if (descrParam != null) { newMenuItem.setToolTipText(descrParam.valueAsString()); } newMenuItem.addActionListener(new ToolPluginMenuAction(this, ext, pluginName)); toolMenu.add(newMenuItem); } catch (Exception e) { LOGGER.error("cannot load Tool-Plugin '" + pluginName + "'", e); JOptionPane.showMessageDialog(this, "Error", "Cannot load Tool-Plugin '" + pluginName + "'", JOptionPane.ERROR_MESSAGE); } } } } return toolMenu; }
From source file:biz.wolschon.finance.jgnucash.JGnucash.java
/** * This method initializes import-menu with * plugins./*from w ww .j a v a 2s . c o m*/ * * @return javax.swing.JMenu */ @SuppressWarnings("unchecked") protected JMenu getImportMenu() { if (importMenu == null) { importMenu = new JMenu(); importMenu.setText("Import"); importMenu.setMnemonic('i'); //importMenu.setEnabled(false);// first we need to load a file PluginManager manager = getPluginManager(); // if we are configured for the plugin-api if (manager != null) { ExtensionPoint toolExtPoint = manager.getRegistry().getExtensionPoint(getPluginDescriptor().getId(), "Importer"); for (Iterator<Extension> it = toolExtPoint.getConnectedExtensions().iterator(); it.hasNext();) { Extension ext = it.next(); String pluginName = "unknown"; try { pluginName = ext.getParameter("name").valueAsString(); JMenuItem newMenuItem = new JMenuItem(); newMenuItem.putClientProperty("extension", ext); Parameter descrParam = ext.getParameter("description"); Parameter iconParam = ext.getParameter("icon"); URL iconUrl = null; if (iconParam != null) { try { iconUrl = getPluginManager() .getPluginClassLoader(ext.getDeclaringPluginDescriptor()) .getResource(iconParam.valueAsString()); if (iconUrl != null) { newMenuItem.setIcon(new ImageIcon(iconUrl)); } } catch (Exception e) { LOGGER.error("cannot load icon for Importer-Plugin '" + pluginName + "'", e); } } newMenuItem.setText(pluginName); if (descrParam != null) { newMenuItem.setToolTipText(descrParam.valueAsString()); } newMenuItem.addActionListener(new ImportPluginMenuAction(this, ext, pluginName)); importMenu.add(newMenuItem); } catch (Exception e) { LOGGER.error("cannot load Importer-Plugin '" + pluginName + "'", e); JOptionPane.showMessageDialog(this, "Error", "Cannot load Importer-Plugin '" + pluginName + "'", JOptionPane.ERROR_MESSAGE); } } } } return importMenu; }
From source file:biz.wolschon.finance.jgnucash.JGnucash.java
/** * This method initializes FileMenu/*from w w w . j a va 2s .c om*/ * including all menu-items added by plugins. * * @return javax.swing.JMenu */ @SuppressWarnings("unchecked") @Override protected JMenu getFileMenu() { if (fileMenu == null) { fileMenu = super.getFileMenu(); fileMenu.setText("File"); fileMenu.setMnemonic('f'); int i = 1; fileMenu.add(getFileSaveMenuItem(), i++); fileMenu.add(getFileSaveAsMenuItem(), i++); // allow plugins to supply file-open and file-save -actions PluginManager manager = getPluginManager(); // if we are configured for the plugin-api if (manager != null) { ExtensionPoint toolExtPoint = manager.getRegistry().getExtensionPoint(getPluginDescriptor().getId(), "DataSource"); for (Iterator<Extension> it = toolExtPoint.getConnectedExtensions().iterator(); it.hasNext();) { Extension ext = it.next(); String pluginName = "unknown"; try { pluginName = ext.getParameter("name").valueAsString(); LOGGER.debug("adding menu-item for DataSource-plugin " + pluginName + " - support for writeTo=" + ext.getParameter("supportsWritingTo")); JMenuItem newMenuItem = new JMenuItem(); newMenuItem.putClientProperty("extension", ext); Parameter descrParam = ext.getParameter("description"); Parameter iconParam = ext.getParameter("icon"); URL iconUrl = null; if (iconParam != null) { try { iconUrl = getPluginManager() .getPluginClassLoader(ext.getDeclaringPluginDescriptor()) .getResource(iconParam.valueAsString()); if (iconUrl != null) { newMenuItem.setIcon(new ImageIcon(iconUrl)); } } catch (Exception e) { LOGGER.error("cannot load icon for Loader-Plugin '" + pluginName + "'", e); } } newMenuItem.setText("open via " + pluginName + "..."); if (descrParam != null) { newMenuItem.setToolTipText(descrParam.valueAsString()); } newMenuItem.addActionListener(new OpenFilePluginMenuAction(this, ext, pluginName)); fileMenu.add(newMenuItem, 1); // Open if (ext.getParameter("supportsWritingTo").valueAsString().equalsIgnoreCase("true")) { LOGGER.debug("Plugin " + pluginName + " also supportes 'write to', adding menu-item"); JMenuItem newSaveAsMenuItem = new JMenuItem(); newSaveAsMenuItem.putClientProperty("extension", ext); newSaveAsMenuItem.setText("Save to via " + pluginName + "..."); if (iconUrl != null) { newMenuItem.setIcon(new ImageIcon(iconUrl)); } newSaveAsMenuItem .addActionListener(new SaveAsFilePluginMenuAction(this, ext, pluginName)); fileMenu.add(newSaveAsMenuItem, 2); // Open } } catch (Exception e) { LOGGER.error("cannot load Loader-Plugin '" + pluginName + "'", e); JOptionPane.showMessageDialog(this, "Error", "Cannot load Loader-Plugin '" + pluginName + "'", JOptionPane.ERROR_MESSAGE); } } } } return fileMenu; }