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.nuclos.client.ui.resplan.header.JHeaderGrid.java

public JHeaderGrid(Orientation orientation, TypesafeListModel<E> model, GroupMapper<E> categoryModel) {
    this.orientation = orientation;
    this.cellExtent = orientation.extentFrom(DEFAULT_CELL_EXTENT);

    this.gridColor = new Color(163, 172, 187);

    this.cellRendererPane = new CellRendererPane();
    this.cellRendererProvider = createDefaultCellRendererProvider();
    this.add(cellRendererPane);

    this.setModel(model);
    this.setCategoryModel(categoryModel);

    // Enable location-sensitive tool-tips (don't fiddle with setting a dummy tooltip,
    // registering the component with the ToolTipManager is the standard Swing way to do it)
    ToolTipManager.sharedInstance().registerComponent(this);

    initializeModel();/*from  www. j  a  v a 2s .  c o m*/

    mouseActionHandler = new MultiActionMouseHandler(new DefaultMouseHandler());
    mouseActionHandler.install(this);
}

From source file:org.openmicroscopy.shoola.agents.treeviewer.browser.BrowserUI.java

/** 
 * Helper method to create the trees hosting the display. 
 * //from w  w  w. java2  s  .  c o  m
 * @param exp The logged in experimenter.
 */
private void createTrees(ExperimenterData exp) {
    treeDisplay = new DnDTree(model.getUserID(), TreeViewerAgent.isAdministrator());
    treeDisplay.addPropertyChangeListener(this);
    String key = "meta pressed A";
    if (UIUtilities.isWindowsOS())
        key = "ctrl pressed A";
    KeyStroke ks = KeyStroke.getKeyStroke(key);
    treeDisplay.getInputMap().put(ks, "none");
    treeDisplay.setVisible(true);
    treeDisplay.setRootVisible(false);
    ToolTipManager.sharedInstance().registerComponent(treeDisplay);
    treeDisplay.setCellRenderer(new TreeCellRenderer(model.getUserID()));
    treeDisplay.setShowsRootHandles(true);
    TreeImageSet root = new TreeImageSet("");
    treeDisplay.setModel(new DefaultTreeModel(root));
    if (model.getBrowserType() != Browser.ADMIN_EXPLORER) {
        TreeImageDisplay node = buildTreeNodes(exp);
        if (node != null)
            treeDisplay.collapsePath(new TreePath(node.getPath()));
    }
    //Add Listeners
    //treeDisplay.requestFocus();
    treeDisplay.addMouseListener(new MouseAdapter() {
        public void mousePressed(MouseEvent e) {
            mousePressedTime = e.getWhen();
            rightClickPad = UIUtilities.isMacOS() && SwingUtilities.isLeftMouseButton(e) && e.isControlDown();
            rightClickButton = SwingUtilities.isRightMouseButton(e);
            ctrl = e.isControlDown();
            if (UIUtilities.isMacOS())
                ctrl = e.isMetaDown();
            leftMouseButton = SwingUtilities.isLeftMouseButton(e);
            if (UIUtilities.isMacOS() || UIUtilities.isLinuxOS())
                onClick(e, false);
        }

        public void mouseReleased(MouseEvent e) {
            leftMouseButton = SwingUtilities.isLeftMouseButton(e);
            if (UIUtilities.isWindowsOS())
                onClick(e, true);
        }

        // public void mouseMoved(MouseEvent e) { rollOver(e); }
    });
    treeDisplay.addMouseMotionListener(new MouseMotionAdapter() {

        public void mouseMoved(MouseEvent e) {
            rollOver(e);
        }
    });
    treeDisplay.addTreeExpansionListener(listener);
    selectionListener = new TreeSelectionListener() {

        public void valueChanged(TreeSelectionEvent e) {
            event = e;
            eventHandledTime = System.currentTimeMillis();

            if (delayedHandlingTreeSelection)
                /* mouse click delayed handling until this event occurred */
                handleTreeSelection();

            switch (keyEvent) {
            case KeyEvent.VK_DOWN:
            case KeyEvent.VK_UP:
                TreePath[] paths = treeDisplay.getSelectionPaths();
                if (paths != null)
                    controller.onClick(Arrays.asList(paths));
                else
                    controller.onClick(new ArrayList<TreePath>());
                break;
            }
        }
    };
    treeDisplay.addTreeSelectionListener(selectionListener);
    //remove standard behaviour
    treeDisplay.addKeyListener(new KeyAdapter() {

        public void keyPressed(KeyEvent e) {
            ctrl = false;
            switch (e.getKeyCode()) {
            case KeyEvent.VK_ENTER:
                ViewCmd cmd = new ViewCmd(model.getParentModel(), true);
                cmd.execute();
                break;
            case KeyEvent.VK_DELETE:
                switch (model.getState()) {
                case Browser.LOADING_DATA:
                case Browser.LOADING_LEAVES:
                    //case Browser.COUNTING_ITEMS:  
                    break;
                default:
                    model.delete();
                }
                break;
            case KeyEvent.VK_CONTROL:
                if (!UIUtilities.isMacOS())
                    ctrl = true;
                break;
            case KeyEvent.VK_META:
                if (UIUtilities.isMacOS())
                    ctrl = true;
                break;
            case KeyEvent.VK_A:
                if (UIUtilities.isWindowsOS() && e.isControlDown()
                        || !UIUtilities.isWindowsOS() && e.isMetaDown()) {
                    handleMultiSelection();
                }
                break;
            case KeyEvent.VK_DOWN:
            case KeyEvent.VK_UP:
            case KeyEvent.VK_RIGHT:
                keyEvent = e.getKeyCode();
                break;
            case KeyEvent.VK_LEFT:
                TreePath[] paths = treeDisplay.getSelectionPaths();
                TreeImageDisplay node;
                Object o;
                for (int i = 0; i < paths.length; i++) {
                    o = paths[i].getLastPathComponent();
                    if (o instanceof TreeImageDisplay) {
                        node = (TreeImageDisplay) o;
                        if (node.isExpanded())
                            node.setExpanded(false);
                    }
                }
            }
        }

        public void keyReleased(KeyEvent e) {
            ctrl = false;
            keyEvent = -1;
        }

    });
}

From source file:org.openmicroscopy.shoola.agents.treeviewer.util.MoveGroupSelectionDialog.java

/**
 * Sets the values where to import the data.
 * /*from   w  w  w  .  j  a  v  a  2  s  . c  o m*/
 * @param targets The values to display.
 */
public void setTargets(Collection<DataObject> targets) {
    Container c = getContentPane();
    c.remove(body);
    c.remove(1);
    treeDisplay = new JTree();
    treeDisplay.setVisible(true);
    treeDisplay.setRootVisible(false);
    ToolTipManager.sharedInstance().registerComponent(treeDisplay);
    treeDisplay.setCellRenderer(new TreeCellRenderer(userID));
    treeDisplay.setShowsRootHandles(true);
    TreeImageSet root = new TreeImageSet("");
    treeDisplay.setModel(new DefaultTreeModel(root));
    treeDisplay.addTreeSelectionListener(this);
    if (CollectionUtils.isEmpty(targets)) {
        buildNoContentPane();
        return;
    }
    Set<TreeImageDisplay> nodes = TreeViewerTranslator.transformHierarchy(new ArrayList<Object>(targets));
    List<TreeImageDisplay> transformedNodes = prepareSortedList(sorter.sort(nodes));
    if (transformedNodes.size() == 0) {
        buildNoContentPane();
        return;
    }
    DefaultTreeModel dtm = (DefaultTreeModel) treeDisplay.getModel();
    buildTreeNode(root, transformedNodes, dtm);
    dtm.reload();
    c.add(new JScrollPane(treeDisplay), BorderLayout.CENTER);
    c.add(buildToolBar(), BorderLayout.SOUTH);
    validate();
    repaint();
}

From source file:org.openmicroscopy.shoola.agents.util.SelectionWizardUI.java

/**
 * Initializes the specified tree/*  ww  w  .j a  va2  s . c o  m*/
 * 
 * @param tree The tree to handle.
 * @param user The user currently logged in.
 */
private void initializeTree(JTree tree, ExperimenterData user) {
    tree.setVisible(true);
    tree.setRootVisible(false);
    ToolTipManager.sharedInstance().registerComponent(tree);
    tree.setCellRenderer(new TreeCellRenderer(user.getId()));
    tree.setShowsRootHandles(true);
    TreeImageSet root = new TreeImageSet("");
    tree.setModel(new DefaultTreeModel(root));
}

From source file:org.pdfsam.guiclient.gui.frames.JMainFrame.java

public JMainFrame() {
    StopWatch stopWatch = new StopWatch();
    stopWatch.start();/*from   ww w  .  jav a2 s . c  o m*/
    log.info("Starting " + GuiClient.getApplicationName() + " Ver. " + GuiClient.getVersion());
    runSplash();
    ToolTipManager.sharedInstance().setDismissDelay(300000);
    initialize();
    closeSplash();
    stopWatch.stop();
    log.info(GuiClient.getApplicationName() + " Ver. " + GuiClient.getVersion() + " "
            + GettextResource.gettext(Configuration.getInstance().getI18nResourceBundle(), "started in ")
            + DurationFormatUtils.formatDurationWords(stopWatch.getTime(), true, true));
}

From source file:org.pentaho.ui.xul.swing.tags.SwingTree.java

@Override
public void layout() {

    XulComponent primaryColumn = this.getElementByXPath("//treecol[@primary='true']"); //$NON-NLS-1$
    XulComponent isaContainer = this.getElementByXPath("treechildren/treeitem[@container='true']"); //$NON-NLS-1$

    isHierarchical = (primaryColumn != null) || (isaContainer != null);

    if (isHierarchical) {
        tree = new JTree();
        if (treeSelectionListener != null) {
            tree.getSelectionModel().addTreeSelectionListener(treeSelectionListener);
        }/*  ww w.j  av a 2s .  c o  m*/
        tree.getSelectionModel().addTreeSelectionListener(new TreeSelectionListener() {
            public void valueChanged(TreeSelectionEvent e) {
                SwingTree.this.changeSupport.firePropertyChange("selectedRows", null, //$NON-NLS-1$
                        SwingTree.this.getSelectedRows());
                SwingTree.this.changeSupport.firePropertyChange("absoluteSelectedRows", null, //$NON-NLS-1$
                        SwingTree.this.getAbsoluteSelectedRows());
                SwingTree.this.fireSelectedItem();
            }
        });
    } else {
        table = new ScrollableJTable();
        if (selectionListener != null) {
            table.getSelectionModel().addListSelectionListener(selectionListener);
        }
        table.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
            public void valueChanged(ListSelectionEvent event) {
                if (event.getValueIsAdjusting() == true) {
                    return;
                }
                SwingTree.this.changeSupport.firePropertyChange("selectedRows", null, //$NON-NLS-1$
                        SwingTree.this.getSelectedRows());
                SwingTree.this.fireSelectedItem();

            }
        });
    }

    JComponent comp = (table != null ? table : tree);
    ToolTipManager.sharedInstance().unregisterComponent(comp);
    if (table != null) {
        ToolTipManager.sharedInstance().unregisterComponent(table.getTableHeader());

        table.setRowHeight(18);
        scrollpane = new JScrollPane(table);
        setupTable();

    } else {
        setupTree();
        scrollpane = new JScrollPane(tree);
    }

    setManagedObject(scrollpane.getViewport());
}

From source file:org.pmedv.blackboard.components.BoardEditor.java

/**
 * Setup the listeners// ww  w  .  jav a2s .  c  o  m
 */
private void initListeners() {
    addMouseMotionListener(new MouseMotionAdapter() {
        @Override
        public void mouseDragged(MouseEvent e) {
            handleMouseDragged(e);
        }

        @Override
        public void mouseMoved(MouseEvent e) {

            Point p = e.getPoint();
            p = BoardUtil.mirrorTransform(p, zoomLayer, e);

            if (editorMode.equals(EditorMode.CHECK_CONNECTIONS)) {
                mouseOverLine = EditorUtils.findMouseOverLine(e, BoardEditor.this);
            } else {
                mouseOverPin = EditorUtils.findPin(e.getX(), e.getY(), BoardEditor.this);
            }

            win.getCustomLabel().setText("x : " + e.getX() + " y : " + e.getY());

            if (mouseOverPin != null) {
                tooltipBuffer.delete(0, tooltipBuffer.length());
                tooltipBuffer.append(mouseOverPin.getNum());
                if (mouseOverPin.getName() != null) {
                    tooltipBuffer.append(" " + mouseOverPin.getName());
                }
                BoardEditor.this.setToolTipText(tooltipBuffer.toString());
                ToolTipManager.sharedInstance()
                        .mouseMoved(new MouseEvent(BoardEditor.this, 0, 0, 0, (int) p.getX(), (int) p.getY(), // X-Y of the mouse for the tool tip
                                0, false));
            } else if (mouseOverLine != null) {
                tooltipBuffer.delete(0, tooltipBuffer.length());
                tooltipBuffer.append("net : " + mouseOverLine.getNetIndex());
                BoardEditor.this.setToolTipText(tooltipBuffer.toString());

                ToolTipManager.sharedInstance()
                        .mouseMoved(new MouseEvent(BoardEditor.this, 0, 0, 0, (int) p.getX(), (int) p.getY(), // X-Y of the mouse for the tool tip
                                0, false));

            } else {
                BoardEditor.this.setToolTipText(null);
            }

        }
    });
    addMouseListener(new MouseAdapter() {
        @Override
        public void mousePressed(MouseEvent e) {
            handleMousePressed(e);
        }

        @Override
        public void mouseReleased(MouseEvent e) {
            handleMouseReleased(e);
        }
    });
    addMouseWheelListener(new MouseWheelListener() {
        @Override
        public void mouseWheelMoved(MouseWheelEvent e) {

            Boolean invertMouse = (Boolean) Preferences.values
                    .get("org.pmedv.blackboard.BoardDesignerPerspective.invertMouse");

            if (invertMouse) {
                if (currentZoomIndex - e.getWheelRotation() < zoomLevels.length
                        && currentZoomIndex - e.getWheelRotation() > 0) {
                    currentZoomIndex -= e.getWheelRotation();
                }
            } else {
                if (currentZoomIndex + e.getWheelRotation() < zoomLevels.length
                        && currentZoomIndex + e.getWheelRotation() > 0) {
                    currentZoomIndex += e.getWheelRotation();
                }
            }

            JXLayer<?> layer = getZoomLayer();
            TransformUI ui = (TransformUI) (Object) layer.getUI();
            DefaultTransformModel model = (DefaultTransformModel) ui.getModel();
            model.setScale(zoomLevels[currentZoomIndex]);
            ctx.getBean(ApplicationWindow.class).getZoomCombo().setSelectedItem(zoomLevels[currentZoomIndex]);
        }
    });
    addMouseMotionListener(AppContext.getContext().getBean(AddTextCommand.class));
}

From source file:org.pmedv.core.gui.ApplicationWindowAdvisorImpl.java

@Override
public void preWindowCreate() {

    log.info("initializing.");

    String laf = (String) Preferences.values.get("org.pmedv.blackboard.BoardDesignerPerspective.lookAndFeel");

    try {/*from  ww w .j  a va2  s  . c o  m*/
        if (laf.equals("Nimbus")) {
            UIManager.setLookAndFeel(new NimbusLookAndFeel());
        } else if (laf.equals("SkyBlue")) {
            Plastic3DLookAndFeel.setPlasticTheme(new SkyBluer());
            UIManager.setLookAndFeel(new Plastic3DLookAndFeel());
            com.jgoodies.looks.Options.setPopupDropShadowEnabled(true);
        } else {
            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
        }
    } catch (Exception e2) {
        log.info("failed to set look and feel.");
    }

    final Color blackboardLightBlue = new Color(225, 234, 242);
    final Color blackBoardDarkBlue = new Color(182, 191, 205);
    final Color blackboardLightGrey = new Color(220, 220, 222);

    UIManager.put("TaskPane.titleBackgroundGradientStart", Color.WHITE);
    UIManager.put("TaskPane.titleBackgroundGradientEnd", blackboardLightBlue);
    UIManager.put("TaksPane.specialTitleBackground", blackboardLightBlue);
    UIManager.put("TaskPane.titleBackground", blackboardLightBlue);
    UIManager.put("TaskPane.borderColor", blackboardLightBlue);
    UIManager.put("TaskPane.background", blackboardLightGrey);
    UIManager.put("TaskPaneContainer.backgroundPainter", new MattePainter(blackBoardDarkBlue));

    log.info("setting look and feel to: " + UIManager.getLookAndFeel());

    // construct app icon

    Image iconImage = resources.getIcon("icon.application").getImage();

    MediaTracker mt = new MediaTracker(win);
    mt.addImage(iconImage, 0);

    try {
        mt.waitForAll();
    } catch (InterruptedException e) {
        // Silently ignore
    }

    InputStream is = getClass().getClassLoader().getResourceAsStream("application.properties");
    Properties properties = new Properties();
    try {
        properties.load(is);
    } catch (IOException e1) {
        properties.setProperty("version", "not set");
    }

    win.setTitle(windowConfig.getConfig().getTitle() + " Version " + properties.get("version"));
    win.setIconImage(iconImage);
    win.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
    win.addWindowListener(win);

    ToolTipManager.sharedInstance().setInitialDelay(100);
    ToolTipManager.sharedInstance().setDismissDelay(1000);

}

From source file:org.processmining.analysis.performance.advanceddottedchartanalysis.ui.DottedChartPanel.java

/**
 * constructor//www  .  j a v a 2 s . c om
 * 
 * @param aDCA
 *            DottedChartAnalysis the Dotted Chart Analysis to be displayed
 * @param aDcModel
 *            DottedChartModel the dottedchartmodel that includes data
 *            structure for dotted chart
 */
public DottedChartPanel(DottedChartAnalysis aDCA) {
    dca = aDCA;
    dcModel = aDCA.getDottedChartModel();
    dcop = aDCA.getDottedChartOptionPanel();
    coUtil = new CoordinationUtil(dcop, dcModel);
    dcModel.initTimeStatistics(dca.getDottedChartOptionPanel().getComponentType());
    viewportZoomX = 1.0;
    viewportZoomY = 1.0;
    BORDER = 10;
    handleRatio = 0.5;
    updWidth = this.getWidth();
    updHight = this.getHeight();
    itemHandle = DottedChartPanel.ITEM_HANDLE_CIRCLE;
    colorBg = new Color(240, 240, 220);
    colorFg = new Color(10, 10, 10);
    // colorLogDark = aDCA.getSettingPanel().getFBcolor();
    // colorLogBright = new Color(210, 210, 200);
    colorTimeLine = new Color(225, 225, 225);
    colorBaseGreen = new Color(50, 100, 100);
    cal = new GregorianCalendar();
    itemColors = new ColorReference();
    itemShapes = new ShapeReference();
    coUtil.updateMilli2pixelsRatio(this.getWidth(), BORDER);
    timeOffset = dcModel.getTimeOffset();
    this.setAutoscrolls(true); // enable synthetic drag events
    this.setOpaque(true);
    this.addMouseMotionListener(this);
    this.addMouseListener(this);
    ToolTipManager.sharedInstance().registerComponent(this);
    ToolTipManager.sharedInstance().setDismissDelay(dismissDelay);
    ToolTipManager.sharedInstance().setInitialDelay(initDelay);
    ToolTipManager.sharedInstance().setReshowDelay(initDelay);
}

From source file:org.prom5.analysis.performance.advanceddottedchartanalysis.ui.DottedChartPanel.java

/**
 * constructor/*from w  w  w.ja  va  2  s. c o  m*/
 * @param aDCA DottedChartAnalysis the Dotted Chart Analysis to be displayed
 * @param aDcModel DottedChartModel the dottedchartmodel that includes data structure for dotted chart
 */
public DottedChartPanel(DottedChartAnalysis aDCA) {
    dca = aDCA;
    dcModel = aDCA.getDottedChartModel();
    dcop = aDCA.getDottedChartOptionPanel();
    coUtil = new CoordinationUtil(dcop, dcModel);
    dcModel.initTimeStatistics(dca.getDottedChartOptionPanel().getComponentType());
    viewportZoomX = 1.0;
    viewportZoomY = 1.0;
    BORDER = 10;
    handleRatio = 0.5;
    updWidth = this.getWidth();
    updHight = this.getHeight();
    itemHandle = DottedChartPanel.ITEM_HANDLE_CIRCLE;
    colorBg = new Color(240, 240, 220);
    colorFg = new Color(10, 10, 10);
    //      colorLogDark = aDCA.getSettingPanel().getFBcolor();
    //      colorLogBright = new Color(210, 210, 200);
    colorTimeLine = new Color(225, 225, 225);
    colorBaseGreen = new Color(50, 100, 100);
    cal = new GregorianCalendar();
    itemColors = new ColorReference();
    itemShapes = new ShapeReference();
    coUtil.updateMilli2pixelsRatio(this.getWidth(), BORDER);
    timeOffset = dcModel.getTimeOffset();
    this.setAutoscrolls(true); //enable synthetic drag events
    this.setOpaque(true);
    this.addMouseMotionListener(this);
    this.addMouseListener(this);
    ToolTipManager.sharedInstance().registerComponent(this);
    ToolTipManager.sharedInstance().setDismissDelay(dismissDelay);
    ToolTipManager.sharedInstance().setInitialDelay(initDelay);
    ToolTipManager.sharedInstance().setReshowDelay(initDelay);
}