Example usage for javax.swing ToolTipManager sharedInstance

List of usage examples for javax.swing ToolTipManager sharedInstance

Introduction

In this page you can find the example usage for javax.swing ToolTipManager sharedInstance.

Prototype

public static ToolTipManager sharedInstance() 

Source Link

Document

Returns a shared ToolTipManager instance.

Usage

From source file:org.sikuli.ide.SikuliIDE.java

private void initTooltip() {
    ToolTipManager tm = ToolTipManager.sharedInstance();
    tm.setDismissDelay(30000);
}

From source file:org.tellervo.desktop.tridasv2.ui.ComponentViewer.java

private void setupTree() {
    treeModel = new DefaultTreeModel(null);
    tree = new JTree(treeModel);

    tree.setCellRenderer(new ComponentTreeCellRenderer());

    // popup menu
    tree.addMouseListener(new PopupListener() {
        @Override//from   w  ww  .  jav  a2 s  .c  o m
        public void showPopup(MouseEvent e) {
            TreePath path = tree.getPathForLocation(e.getX(), e.getY());
            DefaultMutableTreeNode node = (path == null) ? null
                    : (DefaultMutableTreeNode) path.getLastPathComponent();

            if (node == null)
                return;

            // ensure we select the node...
            tree.setSelectionPath(path);

            // get the element
            Element element = (Element) node.getUserObject();

            // create and show the menu
            JPopupMenu popup = new ElementListPopupMenu(element, ComponentViewer.this);
            popup.show(tree, e.getX(), e.getY());
        }
    });
    ToolTipManager.sharedInstance().setInitialDelay(0);

    tree.setToolTipText("");

}

From source file:org.tellervo.desktop.tridasv2.ui.ComponentViewerOld.java

private void setupTree() {
    treeModel = new DefaultTreeModel(null);
    tree = new JTree(treeModel);

    tree.setCellRenderer(new ComponentTreeCellRenderer());

    // popup menu
    tree.addMouseListener(new PopupListener() {
        @Override//from   ww w.  j av a 2s . c  om
        public void showPopup(MouseEvent e) {
            TreePath path = tree.getPathForLocation(e.getX(), e.getY());
            DefaultMutableTreeNode node = (path == null) ? null
                    : (DefaultMutableTreeNode) path.getLastPathComponent();

            if (node == null)
                return;

            // ensure we select the node...
            tree.setSelectionPath(path);

            // get the element
            Element element = (Element) node.getUserObject();

            // create and show the menu
            JPopupMenu popup = new ElementListPopupMenu(element, ComponentViewerOld.this);
            popup.show(tree, e.getX(), e.getY());
        }
    });
    ToolTipManager.sharedInstance().setInitialDelay(0);

    tree.setToolTipText("");

}

From source file:org.trianacode.gui.hci.ApplicationFrame.java

/**
 * Initialises the panels in the main window
 *//*from   www .j av  a2  s . com*/
private void initLayout() {

    GUIEnv.setApplicationFrame(this);
    ColorManager.setDefaultColorModel(new TrianaColorModel());
    ColorManager.registerColorModel(ScriptConstants.SCRIPT_RENDERING_HINT, new ScriptColorModel());

    // do this after all other color loading
    ColorTable.instance().loadUserPrefs();

    TaskGraphView defaultview = new TaskGraphView("Default View");
    TrianaComponentModel compmodel = new TrianaComponentModel(tools, this, this);

    defaultview.setDefaultToolModel(compmodel);
    defaultview.setDefaultOpenGroupModel(compmodel);
    defaultview.registerToolModel(ScriptConstants.SCRIPT_RENDERING_HINT, new ScriptComponentModel());
    defaultview.registerToolModel(TextToolConstants.TEXT_TOOL_RENDERING_HINT, new TextToolComponentModel());
    defaultview.registerToolModel(HiddenToolConstants.HIDDEN_RENDERING_HINT, new HiddenComponentModel());

    TaskGraphView mapview = new TaskGraphView("Map View", defaultview);
    mapview.registerOpenGroupModel(MapConstants.MAP_RENDERING_HINT, new MapComponentModel());
    mapview.registerToolModel(MapConstants.MAP_LOCATION_RENDERING_HINT, new MapLocationComponentModel());

    TaskGraphViewManager.setDefaultTaskGraphView(defaultview);
    TaskGraphViewManager.registerTaskGraphView(MapConstants.MAP_RENDERING_HINT, mapview);

    taskGraphFileHandler = new TaskGraphFileHandler();

    trianaMenuBar = new TrianaMainMenu(this, tools);
    this.setJMenuBar(trianaMenuBar);

    TrianaShutdownHook shutDownHook = new TrianaShutdownHook();
    Runtime.getRuntime().addShutdownHook(shutDownHook);
    getDesktopViewManager().addDesktopViewListener(this);
    this.workspace.add(getDesktopViewManager().getWorkspace(), BorderLayout.CENTER);

    ((TrianaMainMenu) trianaMenuBar).addHelp();

    ToolTreeModel treemodel = new ToolTreeModel(tools);
    toolboxTree = new JTree(treemodel);
    toolboxTree.addFocusListener(this);
    toolboxTree.setCellRenderer(new TrianaTreeRenderer());
    toolmonitor.setTree(toolboxTree);

    treemodel.addTreeModelListener(this);

    ToolTipManager.sharedInstance().registerComponent(toolboxTree);
    ToolTipManager.sharedInstance().setInitialDelay(TOOL_TIP_SHOW_DELAY);
    ToolTipManager.sharedInstance().setDismissDelay(TOOL_TIP_HIDE_DELAY);

    //set up key maps
    MainTrianaKeyMapFactory keymaps = new MainTrianaKeyMapFactory(this, ActionDisplayOptions.DISPLAY_NAME);
    InputMap inputMap = keymaps.getInputMap();
    inputMap.setParent(this.getRootPane().getInputMap());
    this.getRootPane().setInputMap(JComponent.WHEN_FOCUSED, inputMap);
    ActionMap actMap = keymaps.getActionMap();
    actMap.setParent(this.getRootPane().getActionMap());
    this.getRootPane().setActionMap(actMap);

    leaflistener = new LeafListener(toolboxTree, this, tools);

    keymaps = new MainTrianaKeyMapFactory(leaflistener, ActionDisplayOptions.DISPLAY_NAME);
    inputMap = keymaps.getInputMap();
    inputMap.setParent(toolboxTree.getInputMap());
    toolboxTree.setInputMap(JComponent.WHEN_FOCUSED, inputMap);
    actMap = keymaps.getActionMap();
    actMap.setParent(toolboxTree.getActionMap());
    toolboxTree.setActionMap(actMap);

    toolboxTree.addMouseListener(leaflistener);
    toolboxTree.addMouseMotionListener(leaflistener);
    //toolboxTree.setRootVisible(false);
    JPanel toolPanel = new JPanel(new BorderLayout());

    SearchToolBar searchtoolbar = new SearchToolBar("Search", toolboxTree, treemodel);
    searchtoolbar.setFloatable(false);

    toolPanel.add(searchtoolbar, BorderLayout.NORTH);
    JScrollPane scroll = new JScrollPane(toolboxTree);

    toolPanel.add(scroll, BorderLayout.CENTER);

    JSplitPane verticalSplit = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, toolPanel, workspace);

    TrianaToolBar toolbar = new TrianaToolBar("Main ToolBar", this);
    TrianaUnitToolBar unitToolbar = new TrianaUnitToolBar("Unit ToolBar");
    toolbar.setRollover(true);
    unitToolbar.setRollover(true);

    JPanel innerpanel = new JPanel();
    innerpanel.setLayout(new BoxLayout(innerpanel, BoxLayout.X_AXIS));
    innerpanel.add(toolbar);
    innerpanel.add(Box.createHorizontalStrut(10));
    innerpanel.add(unitToolbar);
    innerpanel.add(Box.createHorizontalGlue());

    JPanel outerpanel = new JPanel(new BorderLayout());

    outerpanel.add(innerpanel, BorderLayout.NORTH);
    outerpanel.add(verticalSplit, BorderLayout.CENTER);
    getContentPane().add(outerpanel);
}

From source file:org.tridas.io.gui.control.TricycleController.java

public void startup(MVCEvent argEvent) {
    if (view == null) {
        view = new MainWindow(TricycleModelLocator.getInstance().getTricycleModel());
        TricycleModelLocator.getInstance().setMainWindow(view);
        if (argEvent instanceof StartupEvent) {
            if (((StartupEvent) argEvent).exitOnClose) {
                view.setDefaultCloseOperation(3);
            } else {
                view.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
            }/*from w  ww . j  av a  2s. c  o m*/
        }
        view.setVisible(true);
        ToolTipManager.sharedInstance().setDismissDelay(10000);
    } else {
        view.setVisible(true);
    }

    TricycleModel model = TricycleModelLocator.getInstance().getTricycleModel();

    // Check to see if we should auto update
    if (TricycleModelLocator.getInstance().isAutoUpdate()) {
        model.setAutoUpdate(true);
        CheckForUpdateEvent event = new CheckForUpdateEvent(false);
        event.dispatch();
    }

    // Check to see if tracking should be set
    if (TricycleModelLocator.getInstance().isTracking()) {
        model.setTracking(true);
    }

    // Check to see if we need to ask permission about tracking
    if (!model.isTracking() && !TricycleModelLocator.getInstance().isDontAskTracking()) {
        String[] options = new String[] { I18n.getText("view.popup.tracking.askLater"),
                I18n.getText("view.popup.tracking.no"), I18n.getText("view.popup.tracking.yes")

        };
        ImageIcon aicon = new ImageIcon(IOUtils.getFileInJarURL("icons/128x128/application.png"));

        int response = JOptionPane.showOptionDialog(view,
                WordUtils.wrap(I18n.getText("view.popup.tracking.question"), 50),
                I18n.getText("view.popup.tracking.title"), JOptionPane.YES_NO_CANCEL_OPTION,
                JOptionPane.QUESTION_MESSAGE, aicon, options, options[0]);

        if (response == 2) {
            model.setTracking(true);
            TricycleModelLocator.getInstance().setDontAskTracking(true);
        } else if (response == 1) {
            model.setTracking(false);
            TricycleModelLocator.getInstance().setDontAskTracking(true);
        } else if (response == 0) {
            model.setTracking(false);
            TricycleModelLocator.getInstance().setDontAskTracking(false);
        }
    }
}

From source file:org.ut.biolab.medsavant.MedSavantClient.java

private static void setLAF() {
    try {// w  ww  . j  av a  2  s  . com

        if (ClientMiscUtils.MAC) {
            customizeForMac();
        }

        // UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel"); //Metal works with sliders.
        //UIManager.setLookAndFeel("com.sun.java.swing.plaf.gtk.GTKLookAndFeel"); //GTK doesn't work with sliders.
        //UIManager.setLookAndFeel("javax.swing.plaf.nimbus.NimbusLookAndFeel"); //Nimbus doesn't work with sliders.
        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());

        for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
            LOG.debug("Installed LAF: " + info.getName() + " class: " + info.getClassName());
        }
        LOG.debug("System LAF is: " + UIManager.getSystemLookAndFeelClassName());
        LOG.debug("Cross platform LAF is: " + UIManager.getCrossPlatformLookAndFeelClassName());

        LookAndFeelFactory.addUIDefaultsInitializer(new LookAndFeelFactory.UIDefaultsInitializer() {
            public void initialize(UIDefaults defaults) {
                Map<String, Object> defaultValues = new HashMap<String, Object>();
                defaultValues.put("Slider.trackWidth", new Integer(7));
                defaultValues.put("Slider.majorTickLength", new Integer(6));
                defaultValues.put("Slider.highlight", new ColorUIResource(255, 255, 255));
                defaultValues.put("Slider.horizontalThumbIcon",
                        javax.swing.plaf.metal.MetalIconFactory.getHorizontalSliderThumbIcon());
                defaultValues.put("Slider.verticalThumbIcon",
                        javax.swing.plaf.metal.MetalIconFactory.getVerticalSliderThumbIcon());
                defaultValues.put("Slider.focusInsets", new InsetsUIResource(0, 0, 0, 0));

                for (Map.Entry<String, Object> e : defaultValues.entrySet()) {
                    if (defaults.get(e.getKey()) == null) {
                        LOG.debug("Missing key " + e.getKey() + ", using default value " + e.getValue());
                        defaults.put(e.getKey(), e.getValue());
                    } else {
                        LOG.debug("Found key " + e.getKey() + " with value " + defaults.get(e.getKey()));
                    }
                }
            }
        });

        if (MiscUtils.WINDOWS) {
            UIManager.put("CheckBox.background", new javax.swing.plaf.ColorUIResource(Color.WHITE));
            UIManager.put("Panel.background", new javax.swing.plaf.ColorUIResource(Color.WHITE));
            LookAndFeelFactory.installJideExtension(LookAndFeelFactory.XERTO_STYLE_WITHOUT_MENU);
            /*UIManager.put("JideTabbedPane.tabAreaBackground", new javax.swing.plaf.ColorUIResource(Color.WHITE));
            UIManager.put("JideTabbedPane.background", new javax.swing.plaf.ColorUIResource(Color.WHITE));
            UIManager.put("SidePane.background", new javax.swing.plaf.ColorUIResource(Color.WHITE));*/
        } else {
            LookAndFeelFactory.installJideExtension();
        }

        LookAndFeelFactory.installDefaultLookAndFeelAndExtension();

        System.setProperty("awt.useSystemAAFontSettings", "on");
        System.setProperty("swing.aatext", "true");

        UIManager.put("TabbedPane.contentBorderInsets", new Insets(0, 0, 0, 0));

        //tooltips
        UIManager.put("ToolTip.background", new ColorUIResource(255, 255, 255));
        ToolTipManager.sharedInstance().setDismissDelay(8000);
        ToolTipManager.sharedInstance().setInitialDelay(500);
    } catch (Exception x) {
        LOG.error("Unable to install look & feel.", x);
    }

}

From source file:org.zaproxy.zap.view.MainToolbarPanel.java

private JComboBox<String> getModeSelect() {
    if (modeSelect == null) {
        modeSelect = new JComboBox<>();
        modeSelect.addItem(Constant.messages.getString("view.toolbar.mode.safe.select"));
        modeSelect.addItem(Constant.messages.getString("view.toolbar.mode.protect.select"));
        modeSelect.addItem(Constant.messages.getString("view.toolbar.mode.standard.select"));
        modeSelect.addItem(Constant.messages.getString("view.toolbar.mode.attack.select"));

        modeSelect.setToolTipText(Constant.messages.getString("view.toolbar.mode.tooltip"));
        // Increase the time the tooltip is displayed, to give people a chance to read it!
        ToolTipManager.sharedInstance().setDismissDelay(12000);
        ToolTipManager.sharedInstance().registerComponent(modeSelect);

        // Control wont have finished initialising yet, so get from the params
        Mode mode = Mode.valueOf(Model.getSingleton().getOptionsParam().getViewParam().getMode());
        switch (mode) {
        case safe:
            modeSelect.setSelectedIndex(0);
            break;
        case protect:
            modeSelect.setSelectedIndex(1);
            break;
        case standard:
            modeSelect.setSelectedIndex(2);
            break;
        case attack:
            modeSelect.setSelectedIndex(3);
            break;
        }/*from  ww  w  . j a v a 2  s.co  m*/

        modeSelect.addActionListener(new java.awt.event.ActionListener() {
            @Override
            public void actionPerformed(java.awt.event.ActionEvent e) {
                Mode mode = null;
                switch (modeSelect.getSelectedIndex()) {
                case 0:
                    mode = Mode.safe;
                    break;
                case 1:
                    mode = Mode.protect;
                    break;
                case 2:
                    mode = Mode.standard;
                    break;
                case 3:
                    mode = Mode.attack;
                    break;
                default:
                    return; // Not recognised
                }
                Control.getSingleton().setMode(mode);
            }
        });
    }
    return modeSelect;
}

From source file:phex.gui.common.GUIRegistry.java

private void initializeGUISettings(DGuiSettings guiSettings) {
    // set default values...
    if (SystemUtils.IS_OS_MAC_OSX || SystemUtils.IS_OS_WINDOWS) {
        showTableHorizontalLines = false;
        showTableVerticalLines = false;/*  w w w  . jav a2s . c om*/
    } else {
        showTableHorizontalLines = true;
        showTableVerticalLines = true;
    }
    useLogBandwidthSlider = false;
    showRespectCopyrightNotice = true;

    // sets old values from old cfg...
    ToolTipManager.sharedInstance().setEnabled(InterfacePrefs.DisplayTooltip.get().booleanValue());

    String userLafClass;
    String iconPackName;
    // load values from gui new settings if available.
    if (guiSettings != null) {
        if (guiSettings.isSetLogBandwidthSliderUsed()) {
            useLogBandwidthSlider = guiSettings.isLogBandwidthSliderUsed();
        }
        if (guiSettings.isSetShowRespectCopyrightNotice()) {
            showRespectCopyrightNotice = guiSettings.isShowRespectCopyrightNotice();
        }

        DTableList tableList = guiSettings.getTableList();
        if (tableList != null && tableList.isSetShowHorizontalLines()) {
            showTableHorizontalLines = tableList.isShowHorizontalLines();
        }
        if (tableList != null && tableList.isSetShowVerticalLines()) {
            showTableVerticalLines = tableList.isShowVerticalLines();
        }
        iconPackName = guiSettings.getIconPackName();
        userLafClass = guiSettings.getLookAndFeelClass();
    } else {
        userLafClass = null;
        iconPackName = null;
    }

    if (iconPackName != null) {
        plafIconPack = IconPack.createIconPack(iconPackName);
    }
    if (plafIconPack == null) {
        plafIconPack = IconPack.createDefaultIconPack();
    }

    LookAndFeel laf = LookAndFeelUtils.determineLAF(userLafClass);
    String phexLafClass = laf.getClass().getName();
    if (userLafClass != null && !phexLafClass.equals(userLafClass)) {// in case we had to switch LAF show error.
        JOptionPane.showMessageDialog(GUIRegistry.getInstance().getMainFrame(),
                Localizer.getString("LAF_ErrorLoadingSwitchToDefault"), Localizer.getString("Error"),
                JOptionPane.ERROR_MESSAGE);
    }

    if (phexLafClass.equals(UIManager.getLookAndFeel().getClass().getName())) {
        // in case correct laf is already set just update UI!
        // this must be done to get colors correctly initialized!
        GUIUtils.updateComponentsUI();
    } else {
        try {
            LookAndFeelUtils.setLookAndFeel(laf);
        } catch (ExceptionInInitializerError ex) {
            // headless mode
        } catch (LookAndFeelFailedException e) {// this is supposed to never happen.. since the LAF
                                                // should already be tested to function.
            assert (false);
        }
    }
}

From source file:phex.gui.tabs.library.LibraryTab.java

private JPanel createTreePanel(MouseHandler mouseHandler) {
    JPanel panel = new JPanel();
    CellConstraints cc = new CellConstraints();
    FormLayout layout = new FormLayout("fill:d:grow", // columns
            "fill:d:grow, 1dlu, p"); //rows
    PanelBuilder tabBuilder = new PanelBuilder(layout, panel);

    sharingTreeModel = new SharingTreeModel();
    mainTree = new JTree(sharingTreeModel);
    mainTree.setMinimumSize(new Dimension(0, 0));
    mainTree.setRowHeight(0);/*from www. jav  a 2s .c  om*/
    mainTree.setCellRenderer(new SharingTreeRenderer());
    mainTree.addMouseListener(mouseHandler);

    mainTree.getSelectionModel().addTreeSelectionListener(new SelectionHandler());
    ToolTipManager.sharedInstance().registerComponent(mainTree);

    // open up first level of nodes
    TreeNode root = (TreeNode) sharingTreeModel.getRoot();
    int count = root.getChildCount();
    for (int i = 0; i < count; i++) {
        mainTree.expandPath(new TreePath(new Object[] { root, root.getChildAt(i) }));
    }

    JScrollPane treeScrollPane = new JScrollPane(mainTree);
    tabBuilder.add(treeScrollPane, cc.xywh(1, 1, 1, 1));

    FWToolBar shareToolbar = new FWToolBar(FWToolBar.HORIZONTAL);
    shareToolbar.setBorderPainted(false);
    shareToolbar.setFloatable(false);
    tabBuilder.add(shareToolbar, cc.xy(1, 3));

    FWAction action = new AddShareFolderAction();
    addTabAction(ADD_SHARE_FOLDER_ACTION_KEY, action);
    shareToolbar.addAction(action);

    action = new RemoveShareFolderAction();
    addTabAction(REMOVE_SHARE_FOLDER_ACTION_KEY, action);
    shareToolbar.addAction(action);

    if (SystemUtils.IS_OS_WINDOWS || SystemUtils.IS_OS_MAC_OSX) {
        action = new ExploreFolderAction();
        addTabAction(EXPLORE_FOLDER_ACTION_KEY, action);
    }

    return panel;
}

From source file:phex.gui.tabs.library.LibraryTreePane.java

private void prepareComponent() {
    CellConstraints cc = new CellConstraints();
    FormLayout layout = new FormLayout("fill:d:grow", // columns
            "fill:d:grow, 1dlu, p"); //rows
    PanelBuilder tabBuilder = new PanelBuilder(layout, this);

    sharingTreeModel = new SharingTreeModel();
    mainTree = new JTree(sharingTreeModel);
    mainTree.setMinimumSize(new Dimension(0, 0));
    mainTree.setRowHeight(0);/*from  ww w .  j  a  v a  2  s  . c o m*/
    mainTree.setCellRenderer(new SharingTreeRenderer());
    mainTree.addMouseListener(new MouseHandler());

    mainTree.getSelectionModel().addTreeSelectionListener(new SelectionHandler());
    ToolTipManager.sharedInstance().registerComponent(mainTree);

    // open up first level of nodes
    TreeNode root = (TreeNode) sharingTreeModel.getRoot();
    int count = root.getChildCount();
    for (int i = 0; i < count; i++) {
        mainTree.expandPath(new TreePath(new Object[] { root, root.getChildAt(i) }));
    }

    JScrollPane treeScrollPane = new JScrollPane(mainTree);
    tabBuilder.add(treeScrollPane, cc.xywh(1, 1, 1, 1));

    FWToolBar shareToolbar = new FWToolBar(FWToolBar.HORIZONTAL);
    shareToolbar.setBorderPainted(false);
    shareToolbar.setFloatable(false);
    tabBuilder.add(shareToolbar, cc.xy(1, 3));

    addShareFolderAction = new AddShareFolderAction();
    shareToolbar.addAction(addShareFolderAction);

    removeShareFolderAction = new RemoveShareFolderAction();
    shareToolbar.addAction(removeShareFolderAction);

    if (SystemUtils.IS_OS_WINDOWS || SystemUtils.IS_OS_MAC_OSX) {
        exploreFolderAction = new ExploreFolderAction();
    }

    fileTreePopup = new FWPopupMenu();
    fileTreePopup.addAction(addShareFolderAction);
    fileTreePopup.addAction(removeShareFolderAction);

    if (SystemUtils.IS_OS_WINDOWS || SystemUtils.IS_OS_MAC_OSX) {
        fileTreePopup.addAction(exploreFolderAction);
    }
}