Example usage for javax.swing JMenuItem setToolTipText

List of usage examples for javax.swing JMenuItem setToolTipText

Introduction

In this page you can find the example usage for javax.swing JMenuItem setToolTipText.

Prototype

@BeanProperty(bound = false, preferred = true, description = "The text to display in a tool tip.")
public void setToolTipText(String text) 

Source Link

Document

Registers the text to display in a tool tip.

Usage

From source file:org.orbisgis.sif.components.fstree.TreeNodeFolder.java

@Override
public void feedPopupMenu(JPopupMenu menu) {
    if (menu.getComponentCount() > 0) {
        menu.addSeparator();//from w ww  . j  av a 2  s.  c om
    }
    // Open the folder
    JMenuItem copyPathMenu = new JMenuItem(I18N.tr("Copy the path"));
    copyPathMenu.setToolTipText(I18N.tr("Copy the folder path in the clipboard"));
    copyPathMenu.setActionCommand("TreeNodeFolder:CopyPath");
    copyPathMenu.addActionListener(EventHandler.create(ActionListener.class, this, "onCopyPath"));
    MenuCommonFunctions.updateOrInsertMenuItem(menu, copyPathMenu);
    // Read the file system to update the tree
    JMenuItem updateMenu = new JMenuItem(I18N.tr("Update"), SifIcon.getIcon("refresh"));
    updateMenu.setToolTipText(I18N.tr("Update the content of this folder from the file system"));
    updateMenu.setActionCommand("Update");
    updateMenu.addActionListener(EventHandler.create(ActionListener.class, this, "updateTree"));
    MenuCommonFunctions.updateOrInsertMenuItem(menu, updateMenu);
    // Add a new Sub Folder
    JMenuItem newSubFolder = new JMenuItem(I18N.tr("New folder"), SifIcon.getIcon("folder_add"));
    newSubFolder.setToolTipText(I18N.tr("Create a sub-folder"));
    newSubFolder.setActionCommand("TreeNodeFolder:newSubFolder");
    newSubFolder.addActionListener(EventHandler.create(ActionListener.class, this, "onNewSubFolder"));
    MenuCommonFunctions.updateOrInsertMenuItem(menu, newSubFolder);
    // Remove the folder
    //The root folder cannot be removed
    if (parent instanceof TreeNodeFolder) {
        JMenuItem folderRemove = new JMenuItem(I18N.tr("Delete"), SifIcon.getIcon("remove"));
        folderRemove.setToolTipText(I18N.tr("Remove permanently the folder"));
        folderRemove.setActionCommand("delete");
        folderRemove.addActionListener(EventHandler.create(ActionListener.class, this, "onDeleteFolder"));
        MenuCommonFunctions.updateOrInsertMenuItem(menu, folderRemove, true);
    }
}

From source file:org.orbisgis.view.components.fstree.TreeNodeFolder.java

@Override
public void feedPopupMenu(JPopupMenu menu) {
    if (menu.getComponentCount() > 0) {
        menu.addSeparator();//  w  ww  .ja  v a2  s. com
    }
    // Open the folder
    JMenuItem copyPathMenu = new JMenuItem(I18N.tr("Copy the path"));
    copyPathMenu.setToolTipText(I18N.tr("Copy the folder path in the clipboard"));
    copyPathMenu.setActionCommand("TreeNodeFolder:CopyPath");
    copyPathMenu.addActionListener(EventHandler.create(ActionListener.class, this, "onCopyPath"));
    MenuCommonFunctions.updateOrInsertMenuItem(menu, copyPathMenu);
    // Read the file system to update the tree
    JMenuItem updateMenu = new JMenuItem(I18N.tr("Update"), OrbisGISIcon.getIcon("arrow_refresh"));
    updateMenu.setToolTipText(I18N.tr("Update the content of this folder from the file system"));
    updateMenu.setActionCommand("Update");
    updateMenu.addActionListener(EventHandler.create(ActionListener.class, this, "updateTree"));
    MenuCommonFunctions.updateOrInsertMenuItem(menu, updateMenu);
    // Add a new Sub Folder
    JMenuItem newSubFolder = new JMenuItem(I18N.tr("New folder"), OrbisGISIcon.getIcon("folder_add"));
    newSubFolder.setToolTipText(I18N.tr("Create a sub-folder"));
    newSubFolder.setActionCommand("TreeNodeFolder:newSubFolder");
    newSubFolder.addActionListener(EventHandler.create(ActionListener.class, this, "onNewSubFolder"));
    MenuCommonFunctions.updateOrInsertMenuItem(menu, newSubFolder);
    // Remove the folder
    //The root folder cannot be removed
    if (parent instanceof TreeNodeFolder) {
        JMenuItem folderRemove = new JMenuItem(I18N.tr("Delete"), OrbisGISIcon.getIcon("remove"));
        folderRemove.setToolTipText(I18N.tr("Remove permanently the folder"));
        folderRemove.setActionCommand("delete");
        folderRemove.addActionListener(EventHandler.create(ActionListener.class, this, "onDeleteFolder"));
        MenuCommonFunctions.updateOrInsertMenuItem(menu, folderRemove, true);
    }
}

From source file:org.orbisgis.view.map.mapsManager.TreeLeafMapContextFile.java

@Override
public void feedPopupMenu(JPopupMenu menu) {
    super.feedPopupMenu(menu);
    if (!isLoaded()) {
        JMenuItem folderRemove = new JMenuItem(I18N.tr("Delete"), OrbisGISIcon.getIcon("remove"));
        folderRemove.setToolTipText(I18N.tr("Remove permanently the map"));
        folderRemove.setActionCommand("delete");
        folderRemove.addActionListener(EventHandler.create(ActionListener.class, this, "onDeleteFile"));
        MenuCommonFunctions.updateOrInsertMenuItem(menu, folderRemove);
    }//from   www.  j a v a2 s  .  c om
}

From source file:pl.otros.logview.gui.LogViewPanel.java

private void addMarkerToMenu(JMenu menu, AutomaticMarker automaticMarker, HashMap<String, JMenu> marksGroups,
        boolean mode) {
    String[] groups = automaticMarker.getMarkerGroups();
    if (groups == null || groups.length == 0) {
        groups = new String[] { "" };
    }/*from  w w  w  .  ja v a 2s. com*/
    for (String g : groups) {
        JMenuItem markerMenuItem = new JMenuItem(automaticMarker.getName());

        Icon icon = new ColorIcon(automaticMarker.getColors().getBackground(),
                automaticMarker.getColors().getForeground(), 16, 16);
        markerMenuItem.setIcon(icon);
        markerMenuItem.setToolTipText(automaticMarker.getDescription());
        markerMenuItem.addActionListener(
                new AutomaticMarkUnamrkActionListener(dataTableModel, automaticMarker, mode, statusObserver));
        if (g.length() > 0) {
            JMenu m = marksGroups.get(g);
            if (m == null) {
                m = new JMenu(g);
                marksGroups.put(g, m);
                menu.add(m);
            }
            m.add(markerMenuItem);
        } else {
            menu.add(markerMenuItem);
        }
    }

}

From source file:savant.view.swing.FrameCommandBar.java

/**
 * Create Tools menu for commandBar.  This is common to all track types.
 *//*from   ww w . ja  v a  2 s.  c  om*/
private JMenu createToolsMenu() {
    JMenu menu = new JMenu("Tools");
    JMenuItem item = new JCheckBoxMenuItem("Lock X Axis");
    item.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            graphPane.setLocked(!graphPane.isLocked());
        }
    });
    menu.add(item);

    // TODO: experimental feature which doesn't quite work yet
    final JMenuItem itemy = new JCheckBoxMenuItem("Lock Y Axis");
    itemy.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            System.out.println("Trying to locking Y max: " + !itemy.isSelected());
            graphPane.setYMaxLocked(itemy.isSelected());
        }
    });
    //menu.add(itemy);

    item = new JMenuItem("Copy URL to Clipboard");
    item.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            Toolkit.getDefaultToolkit().getSystemClipboard()
                    .setContents(new StringSelection(mainTrack.getDataSource().getURI().toString()), null);
        }
    });
    menu.add(item);

    DataFormat df = mainTrack.getDataFormat();
    if (df == DataFormat.SEQUENCE) {
        menu.add(new JSeparator());
        JMenuItem copyItem = new JMenuItem("Copy Sequence to Clipboard");
        copyItem.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent ae) {
                try {
                    LocationController lc = LocationController.getInstance();
                    byte[] seq = ((SequenceTrack) mainTrack).getSequence(lc.getReferenceName(), lc.getRange());
                    Toolkit.getDefaultToolkit().getSystemClipboard()
                            .setContents(new StringSelection(new String(seq)), null);
                } catch (Throwable x) {
                    LOG.error(x);
                    DialogUtils.displayError("Unable to copy sequence to clipboard.");
                }
            }
        });
        menu.add(copyItem);

        setAsGenomeButton = new JCheckBoxMenuItem("Set as Genome");
        setAsGenomeButton.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                Genome newGenome = Genome.createFromTrack(mainTrack);
                GenomeController.getInstance().setGenome(newGenome);
            }
        });
        menu.add(setAsGenomeButton);
        menu.addMenuListener(new MenuAdapter() {
            @Override
            public void menuSelected(MenuEvent me) {
                Track seqTrack = (Track) GenomeController.getInstance().getGenome().getSequenceTrack();
                if (seqTrack == mainTrack) {
                    setAsGenomeButton.setSelected(true);
                    setAsGenomeButton.setEnabled(false);
                    setAsGenomeButton.setToolTipText("This track is already the reference sequence");
                } else {
                    setAsGenomeButton.setSelected(false);
                    setAsGenomeButton.setEnabled(true);
                    setAsGenomeButton.setToolTipText("Use this track as the reference sequence");
                }
            }
        });
    } else if (df == DataFormat.ALIGNMENT) {
        menu.add(new JSeparator());

        item = new JMenuItem("Filter...");
        item.setToolTipText("Control how records are filtered");

        item.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                new BAMFilterDialog(DialogUtils.getMainWindow(), (BAMTrack) mainTrack).setVisible(true);
            }
        });
        menu.add(item);
    } else if (df == DataFormat.RICH_INTERVAL) {
        menu.add(new JSeparator());

        final JMenuItem bookmarkAll = new JMenuItem("Bookmark All Features");
        bookmarkAll.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                DataSource ds = (DataSource) mainTrack.getDataSource();
                if (DialogUtils.askYesNo("Bookmark All Features ",
                        String.format("This will create %d bookmarks.  Are you sure you want to do this?",
                                ds.getDictionaryCount())) == DialogUtils.YES) {
                    ds.addDictionaryToBookmarks();
                    Savant.getInstance().displayBookmarksPanel();
                }
            }
        });
        menu.add(bookmarkAll);

        menu.addMenuListener(new MenuAdapter() {
            @Override
            public void menuSelected(MenuEvent me) {
                bookmarkAll.setEnabled(mainTrack.getDataSource() instanceof DataSource
                        && ((DataSource) mainTrack.getDataSource()).getDictionaryCount() > 0);
            }
        });
    }
    return menu;
}

From source file:studio.ui.Studio.java

private void rebuildMenus(TabIndexChanged event) {
    AppMenuBar appMenubar = getJMenuBar() instanceof AppMenuBar ? (AppMenuBar) getJMenuBar() : null;
    ToolBarActions toolBar = null;/*from   ww  w.ja va  2s.c  o m*/
    ActionMenu menuBar = null;
    if (appToolbar == null && appMenubar == null) {
        appToolbar = new ToolBarActions();
        getContentPane().add(appToolbar, BorderLayout.NORTH);
        appMenubar = new AppMenuBar();
        setJMenuBar(appMenubar);
        toolBar = new ToolBarActions("File");
        menuBar = new ActionMenu("File", 'f', "File operations", (MouseAdapter) null);
        Action action = new NewFileAction(tabEditors, tabConsoles);

        JPopupMenu popupMenu = new JPopupMenu();

        JMenuItem item = new JMenuItem("Script");
        item.setToolTipText("New script");
        item.addMouseListener(new ActionHintsListener(tabEditors, "Create new script"));
        item.addActionListener(action);
        popupMenu.add(item);

        item = new JMenuItem("Project");
        item.setToolTipText("New project");
        item.addMouseListener(new ActionHintsListener(tabEditors, "Create new project"));
        try {
            item.addActionListener(new AddProjectAction(treeProjects));
            popupMenu.add(item);
        } catch (StudioException ex) {
        }

        JButton button = new DropDownButton(action, popupMenu);
        if (button instanceof DataListener) {
            tabEditors.addFireDataListener((DataListener) button);
        }
        button.addMouseListener(new ActionHintsListener(tabEditors, action));
        toolBar.add(button);
        menuBar.add(new ActionMenuItem(action, new ActionHintsListener(tabEditors, action)));

        action = new OpenFileAction(tabEditors, tabConsoles);
        menuBar.add(new ActionMenuItem(action, new ActionHintsListener(tabEditors, action)));
        popupMenu = null;
        if (studioConfig.getOpenedFiles() != null && !studioConfig.getOpenedFiles().isEmpty()) {
            popupMenu = new JPopupMenu();
            int pos = 0;
            for (EditorFile file : studioConfig.getOpenedFiles()) {
                item = new JMenuItem((char) (pos + 48) + " " + file.getPath(), pos + 48);
                item.addMouseListener(new ActionHintsListener(tabEditors, "Open file " + file));
                popupMenu.add(item);
                if (++pos > 9) {
                    break;
                }
            }
        }
        button = new DropDownButton(action, popupMenu);
        if (button instanceof DataListener) {
            tabEditors.addFireDataListener((DataListener) button);
        }
        button.addMouseListener(new ActionHintsListener(tabEditors, action));
        toolBar.add(button);
        appToolbar.add(toolBar);
        appMenubar.add(menuBar);

        appToolbar.add(new ToolBarActions("KDB+"));
        appMenubar.add(new ActionMenu("KDB+", 'k', "KDB+ databse operations", (MouseAdapter) null));
        appToolbar.add(new ToolBarActions("Edit"));
        appMenubar.add(new ActionMenu("Edit", 'E', "Editor operations", (MouseAdapter) null));
        toolBar = new ToolBarActions("Options");
        appToolbar.add(toolBar);
        menuBar = new ActionMenu("Tools", 'T', "Tools", (MouseAdapter) null);
        ActionMenu opMenuBar = new ActionMenu("Options", 'O', "Studio settings", (MouseAdapter) null);
        ActionMenu lfMenuBar = new ActionMenu("Look and feel", 'L', "L&F", (MouseAdapter) null);
        LookAndFeelAction.getActionLookAndFeel(this, lfMenuBar, studioConfig);
        opMenuBar.add(lfMenuBar);
        opMenuBar.addSeparator();
        action = new EditorSettingsAction(this);
        opMenuBar.add(new ActionMenuItem(action, new ActionHintsListener(tabEditors, action)));
        action = new TokensSettingsAction(this);
        opMenuBar.add(new ActionMenuItem(action, new ActionHintsListener(tabEditors, action)));
        opMenuBar.addSeparator();
        action = new ConsoleSettingsAction(this);
        opMenuBar.add(new ActionMenuItem(action, new ActionHintsListener(tabEditors, action)));
        opMenuBar.addSeparator();
        action = new ConnectionsSettingsAction(treeConnections);
        opMenuBar.add(new ActionMenuItem(action, new ActionHintsListener(tabEditors, action)));
        menuBar.add(opMenuBar);
        opMenuBar.addSeparator();
        action = new GlobalSettingsAction(this);
        opMenuBar.add(new ActionMenuItem(action, new ActionHintsListener(tabEditors, action)));
        appMenubar.add(menuBar);
        opMenuBar.addSeparator();
        action = new ProjectSettingsAction(this);
        opMenuBar.add(new ActionMenuItem(action, new ActionHintsListener(tabEditors, action)));
        appMenubar.add(menuBar);
        menuBar = new ActionMenu("Help", 'H', "Help...", (MouseAdapter) null);
        action = new VisitKxAction();
        menuBar.add(new ActionMenuItem(action, new ActionHintsListener(tabEditors, action)));
        menuBar.addSeparator();
        action = new VisitWroclawAction();
        menuBar.add(new ActionMenuItem(action, new ActionHintsListener(tabEditors, action)));
        menuBar.addSeparator();
        action = new KeyListAction(tabEditors);
        menuBar.add(new ActionMenuItem(action, new ActionHintsListener(tabEditors, action)));
        menuBar.addSeparator();
        action = new AboutAction(tabEditors);
        menuBar.add(new ActionMenuItem(action, new ActionHintsListener(tabEditors, action)));
        appMenubar.add(menuBar);
        menuBar.addSeparator();
        action = new CheckUpdate(this);
        menuBar.add(new ActionMenuItem(action, new ActionHintsListener(tabEditors, action)));
        appMenubar.add(menuBar);
        toolBar = null;

        this.setJMenuBar(appMenubar);
    }

    appToolbar.getToolBar("Edit").setVisible(event != null && event.getData() != -1);
    appToolbar.getToolBar("Options").setVisible(event != null && event.getData() != -1);
    appToolbar.getToolBar("KDB+").setVisible(event != null && event.getData() != -1);
    appToolbar.getToolBar("File").setVisible(event != null && event.getData() != -1);

    appMenubar.getMenu("Edit").setVisible(event != null && event.getData() != -1);
    appMenubar.getMenu("Tools").setVisible(event != null && event.getData() != -1);
    appMenubar.getMenu("KDB+").setVisible(event != null && event.getData() != -1);
    appMenubar.getMenu("File").setVisible(event != null && event.getData() != -1);

    if (event != null && event.getSource() instanceof EditorsTabbedPane && event.getData() != -1) {
        Editor editor = ((EditorsTabbedPane) event.getSource()).getEditor(event.getData());
        if (editor != null) {
            JPopupMenu menu = editor.getComponentPopupMenu();
            if (menu != null) {
                for (int count = 0; count < menu.getComponentCount(); count++) {
                    if (menu.getComponent(count) instanceof JMenuItem) {
                        JMenuItem menuItem = (JMenuItem) menu.getComponent(count);
                        if (menuItem.getAction().getClass() == SaveAction.class) {
                            appToolbar.getToolBar("File").update(tabEditors, menuItem.getAction(), true);
                            appMenubar.getMenu("File").update(tabEditors, menuItem.getAction(), true);
                        } else {
                            if (menuItem.getAction().getClass() == SaveAsAction.class
                                    || menuItem.getAction().getClass() == SaveAllAction.class) {
                                appToolbar.getToolBar("File").update(tabEditors, menuItem.getAction());
                                appMenubar.getMenu("File").update(tabEditors, menuItem.getAction());
                            } else {
                                if (menuItem.getAction().getClass() == CloseAction.class) {
                                    appToolbar.getToolBar("File").update(tabEditors, menuItem.getAction(),
                                            true);
                                    appMenubar.getMenu("File").update(tabEditors, menuItem.getAction(), true);
                                } else {
                                    if (menuItem.getAction().getClass() == CloseAllAction.class) {
                                        appToolbar.getToolBar("File").update(tabEditors, menuItem.getAction());
                                        appMenubar.getMenu("File").update(tabEditors, menuItem.getAction());
                                    } else {
                                        if (menuItem.getAction().getClass() == RunAction.class
                                                || menuItem.getAction().getClass() == RunLineAction.class
                                                || menuItem.getAction().getClass() == CancelRunAction.class) {
                                            appToolbar.getToolBar("KDB+").update(tabEditors,
                                                    menuItem.getAction());
                                            appMenubar.getMenu("KDB+").update(tabEditors, menuItem.getAction());
                                        } else {
                                            if (menuItem.getAction().getClass() == ExtKit.ReplaceAction.class
                                                    || menuItem.getAction()
                                                            .getClass() == ActionFactory.RedoAction.class
                                                    || menuItem.getAction()
                                                            .getClass() == ActionFactory.UndoAction.class
                                                    || menuItem.getAction()
                                                            .getClass() == BaseKit.CopyAction.class
                                                    || menuItem.getAction()
                                                            .getClass() == BaseKit.PasteAction.class
                                                    || menuItem.getAction()
                                                            .getClass() == ExtKit.GotoAction.class
                                                    || menuItem.getAction()
                                                            .getClass() == BaseKit.SelectAllAction.class
                                                    || menuItem.getAction()
                                                            .getClass() == BaseKit.SelectLineAction.class
                                                    || menuItem.getAction()
                                                            .getClass() == BaseKit.CutAction.class) {
                                                appToolbar.getToolBar("Edit").update(tabEditors,
                                                        menuItem.getAction());
                                                if (menuItem.getAction().getClass() == ExtKit.GotoAction.class
                                                        || menuItem.getAction()
                                                                .getClass() == BaseKit.CopyAction.class
                                                        || menuItem.getAction()
                                                                .getClass() == BaseKit.SelectAllAction.class) {
                                                    appMenubar.getMenu("Edit").update(tabEditors,
                                                            menuItem.getAction(), true);
                                                } else {
                                                    appMenubar.getMenu("Edit").update(tabEditors,
                                                            menuItem.getAction());
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    if (event != null && event.getData() != -1 && event.getSource() instanceof EditorsTabbedPane
            && ((EditorsTabbedPane) event.getSource()).getEditor(event.getData()) != null) {
        ((EditorsTabbedPane) event.getSource()).getEditor(event.getData()).requestFocus();
    }
}