Example usage for javax.swing JComponent getToolTipText

List of usage examples for javax.swing JComponent getToolTipText

Introduction

In this page you can find the example usage for javax.swing JComponent getToolTipText.

Prototype

public String getToolTipText() 

Source Link

Document

Returns the tooltip string that has been set with setToolTipText.

Usage

From source file:de.ailis.xadrian.frames.MainFrame.java

/**
 * Installs status handler for the specified component an all its child
 * components./*from   w  w w  .ja  v a2  s  . c  o m*/
 *
 * @param component
 *            The component to install the status handler for.
 */
private void installStatusHandler(final JComponent component) {
    final JLabel statusBar = this.statusBar;
    final String text = component.getToolTipText();
    if (text != null && !text.isEmpty()) {
        component.addMouseListener(new MouseAdapter() {
            @Override
            public void mouseExited(final MouseEvent e) {
                statusBar.setText(" ");
            }

            @Override
            public void mouseEntered(final MouseEvent e) {
                statusBar.setText(component.getToolTipText());
            }
        });
    }
    for (final Component child : component.getComponents()) {
        if (!(child instanceof JComponent))
            continue;
        installStatusHandler((JComponent) child);
    }
    if (component instanceof JMenu) {
        for (final MenuElement menuElement : ((JMenu) component).getSubElements()) {
            if (!(menuElement instanceof JComponent))
                continue;
            installStatusHandler((JComponent) menuElement);
        }
    }
}

From source file:org.nuclos.client.genericobject.GenericObjectCollectController.java

private void markFieldInHistoricalView(CollectableGenericObjectWithDependants clctlowdCurrent,
        String sFieldName, CollectableField clctfShown) {
    if (clctlowdCurrent != null) {
        final CollectableField clctf = clctlowdCurrent.getField(sFieldName);
        if (!clctfShown.equals(clctf)) {
            final Collection<CollectableComponent> collclctcomp = layoutrootDetails
                    .getCollectableComponentsFor(sFieldName);
            if (!collclctcomp.isEmpty()) {
                final CollectableComponent clctcomp = collclctcomp.iterator().next();
                final JComponent compFocussable = clctcomp.getFocusableComponent();
                String initialToolTip = (String) compFocussable.getClientProperty("initialToolTip");
                if (initialToolTip == null) {
                    initialToolTip = StringUtils.emptyIfNull(compFocussable.getToolTipText());
                    compFocussable.putClientProperty("initialToolTip", initialToolTip);
                }/*from ww w  . j a va2 s. co m*/
                if (clctcomp instanceof CollectableComboBox) {
                    CollectableComboBox clctcmbx = (CollectableComboBox) clctcomp;
                    clctcmbx.getJComboBox().setRenderer(clctcmbx.new CollectableFieldRenderer() {

                        @Override
                        protected void paintComponent(Graphics g) {
                            setBackground(colorHistoricalChanged);
                            super.paintComponent(g);
                        }
                    });
                } else
                    compFocussable.setBackground(colorHistoricalChanged);
                final String sToolTip = getSpringLocaleDelegate().getMessage("GenericObjectCollectController.4",
                        "{0} [Ge\u00e4ndert; aktueller Wert: \"{1}\"]", initialToolTip, clctf.toString());
                compFocussable.setToolTipText(sToolTip);
                clctcomp.getJComponent().setToolTipText(sToolTip);
                // todo: mark fields which are not tracked in logbook?
            }
        }
    }
}

From source file:org.nuclos.client.ui.resplan.header.JHeaderGrid.java

@Override
public String getToolTipText(MouseEvent event) {
    int index = stripAtPoint(event.getPoint());
    if (index != -1) {
        JComponent renderer = setupCellRenderer(model.getElementAt(index), false);
        return renderer.getToolTipText();
    } else {//from  www. j  av  a2  s  . c  o m
        return getToolTipText();
    }
}

From source file:org.openmicroscopy.shoola.agents.util.ui.ScriptComponent.java

/**
 * Creates a new instance./*w  ww.  jav  a2  s  . com*/
 * 
 * @param component The component to host.
 * @param name The name of the parameter
 */
ScriptComponent(JComponent component, String name) {
    if (component == null)
        throw new IllegalArgumentException("No component specified.");
    if (name == null)
        name = DEFAULT_TEXT;
    if (component instanceof NumericalTextField)
        ((NumericalTextField) component).setHorizontalAlignment(JTextField.LEFT);
    this.component = component;
    this.name = name;
    parentIndex = null;
    //format
    if (!name.equals(DEFAULT_TEXT))
        name = " " + name + ":";

    if (name.contains(ScriptObject.PARAMETER_SEPARATOR)) {
        label = UIUtilities.setTextFont(
                name.replace(ScriptObject.PARAMETER_SEPARATOR, ScriptObject.PARAMETER_UI_SEPARATOR));
    } else {
        label = UIUtilities.setTextFont(name);
    }
    label.setToolTipText(component.getToolTipText());
    required = false;
}