Java JSplitPane addTooltipsToSplitter(final JSplitPane splitpane, final String hide, final String reveal)

Here you can find the source of addTooltipsToSplitter(final JSplitPane splitpane, final String hide, final String reveal)

Description

Add Tooltips to the Splitter arrow icons.

License

Open Source License

Parameter

Parameter Description
splitpane a parameter
hide a parameter
reveal a parameter

Declaration


public static void addTooltipsToSplitter(final JSplitPane splitpane, final String hide, final String reveal) 

Method Source Code


//package com.java2s;
// it under the terms of the GNU General Public License as published by

import javax.swing.*;

import javax.swing.plaf.basic.BasicSplitPaneDivider;

import java.awt.*;

public class Main {
    /***********************************************************************************************
       * Add Tooltips to the Splitter arrow icons.
       */* ww  w.  java 2 s .  c om*/
       * @param splitpane
       * @param hide
       * @param reveal
       */

    public static void addTooltipsToSplitter(final JSplitPane splitpane, final String hide, final String reveal) {
        final int intComponentCount;

        // See: http://forums.sun.com/thread.jspa?threadID=714732&tstart=23790
        // How to add the ToolTip to the little widgets in the JSplitpane
        intComponentCount = splitpane.getComponentCount();

        for (int i = 0; i < intComponentCount; i++) {
            final Component component;

            component = splitpane.getComponent(i);

            if (component instanceof BasicSplitPaneDivider) {
                final BasicSplitPaneDivider divider;
                final int subComponentCount;

                divider = (BasicSplitPaneDivider) component;

                subComponentCount = divider.getComponentCount();

                if (subComponentCount == 2) {
                    if ((divider.getComponent(0) instanceof JButton)
                            && (divider.getComponent(1) instanceof JButton)) {
                        ((JButton) divider.getComponent(0)).setToolTipText(hide);
                        ((JButton) divider.getComponent(1)).setToolTipText(reveal);
                    }
                }
            }
        }
    }
}

Related

  1. applyDefaultProperties(final JSplitPane comp)
  2. createSplitPane(int newOrientation, Component newLeftComponent, Component newRightComponent)
  3. createSplitPane(int newOrientation, Component newLeftComponent, Component newRightComponent)
  4. createSplitPane(int orientation, Component left, Component right)