javax.swing.ToolTipManager Java Examples

The following examples show how to use javax.swing.ToolTipManager. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SeaGlassDesktopIconUI.java    From seaglass with Apache License 2.0 6 votes vote down vote up
protected void installComponents() {
    if (UIManager.getBoolean("InternalFrame.useTaskBar")) {
        iconPane = new JToggleButton(frame.getTitle(), frame.getFrameIcon()) {
            public String getToolTipText() {
                return getText();
            }

            public JPopupMenu getComponentPopupMenu() {
                return frame.getComponentPopupMenu();
            }
        };
        ToolTipManager.sharedInstance().registerComponent(iconPane);
        iconPane.setFont(desktopIcon.getFont());
        iconPane.setBackground(desktopIcon.getBackground());
        iconPane.setForeground(desktopIcon.getForeground());
    } else {
        iconPane = new SeaGlassInternalFrameTitlePane(frame);
        iconPane.setName("InternalFrame.northPane");
    }
    desktopIcon.setLayout(new BorderLayout());
    desktopIcon.add(iconPane, BorderLayout.CENTER);
}
 
Example #2
Source File: Test6657026.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) throws InterruptedException {
    ToolTipManager manager = ToolTipManager.sharedInstance();
    if (DISMISS != manager.getDismissDelay()) {
        throw new Error("unexpected dismiss delay");
    }
    if (INITIAL != manager.getInitialDelay()) {
        throw new Error("unexpected initial delay");
    }
    if (RESHOW != manager.getReshowDelay()) {
        throw new Error("unexpected reshow delay");
    }
    manager.setDismissDelay(DISMISS + 1);
    manager.setInitialDelay(INITIAL + 1);
    manager.setReshowDelay(RESHOW + 1);

    ThreadGroup group = new ThreadGroup("$$$");
    Thread thread = new Thread(group, new Test6657026());
    thread.start();
    thread.join();
}
 
Example #3
Source File: ChartPanel.java    From openstock with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Handles a 'mouse entered' event. This method changes the tooltip delays
 * of ToolTipManager.sharedInstance() to the possibly different values set
 * for this chart panel.
 *
 * @param e  the mouse event.
 */
@Override
public void mouseEntered(MouseEvent e) {
    if (!this.ownToolTipDelaysActive) {
        ToolTipManager ttm = ToolTipManager.sharedInstance();

        this.originalToolTipInitialDelay = ttm.getInitialDelay();
        ttm.setInitialDelay(this.ownToolTipInitialDelay);

        this.originalToolTipReshowDelay = ttm.getReshowDelay();
        ttm.setReshowDelay(this.ownToolTipReshowDelay);

        this.originalToolTipDismissDelay = ttm.getDismissDelay();
        ttm.setDismissDelay(this.ownToolTipDismissDelay);

        this.ownToolTipDelaysActive = true;
    }
}
 
Example #4
Source File: SlingServerTreeManager.java    From aem-ide-tooling-4-intellij with Apache License 2.0 6 votes vote down vote up
@Override
public void dispose() {
    final SlingServerTreeBuilder builder = myBuilder;
    if(builder != null) {
        Disposer.dispose(builder);
        myBuilder = null;
    }

    final Tree aTree = tree;
    if(aTree != null) {
        ToolTipManager.sharedInstance().unregisterComponent(aTree);
        for(KeyStroke keyStroke : aTree.getRegisteredKeyStrokes()) {
            aTree.unregisterKeyboardAction(keyStroke);
        }
        tree = null;
    }

    final KeyMapListener listener = myKeyMapListener;
    if(listener != null) {
        myKeyMapListener = null;
        listener.stopListen();
    }
}
 
Example #5
Source File: Installer.java    From constellation with Apache License 2.0 6 votes vote down vote up
@Override
public void restored() {
    // Menus are lightweight, GLCanvas is heavyweight. This means that menus will appear under canvases.
    // Fix this by making menus heavyweight.
    // See http://java.sun.com/products/jfc/tsc/articles/mixing/
    // See http://java.sun.com/developer/technicalArticles/GUI/mixing_components/index.html
    // Google for jogl lightweight
    JPopupMenu.setDefaultLightWeightPopupEnabled(false);
    ToolTipManager.sharedInstance().setLightWeightPopupEnabled(false);
}
 
Example #6
Source File: Test6657026.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) throws InterruptedException {
    ToolTipManager manager = ToolTipManager.sharedInstance();
    if (DISMISS != manager.getDismissDelay()) {
        throw new Error("unexpected dismiss delay");
    }
    if (INITIAL != manager.getInitialDelay()) {
        throw new Error("unexpected initial delay");
    }
    if (RESHOW != manager.getReshowDelay()) {
        throw new Error("unexpected reshow delay");
    }
    manager.setDismissDelay(DISMISS + 1);
    manager.setInitialDelay(INITIAL + 1);
    manager.setReshowDelay(RESHOW + 1);

    ThreadGroup group = new ThreadGroup("$$$");
    Thread thread = new Thread(group, new Test6657026());
    thread.start();
    thread.join();
}
 
Example #7
Source File: Test6657026.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) throws InterruptedException {
    ToolTipManager manager = ToolTipManager.sharedInstance();
    if (DISMISS != manager.getDismissDelay()) {
        throw new Error("unexpected dismiss delay");
    }
    if (INITIAL != manager.getInitialDelay()) {
        throw new Error("unexpected initial delay");
    }
    if (RESHOW != manager.getReshowDelay()) {
        throw new Error("unexpected reshow delay");
    }
    manager.setDismissDelay(DISMISS + 1);
    manager.setInitialDelay(INITIAL + 1);
    manager.setReshowDelay(RESHOW + 1);

    ThreadGroup group = new ThreadGroup("$$$");
    Thread thread = new Thread(group, new Test6657026());
    thread.start();
    thread.join();
}
 
Example #8
Source File: MainPanel.java    From openvisualtraceroute with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * Init the component
 */
private void init() {
	if (!Env.INSTANCE.isOpenGLAvailable()) {
		LOGGER.warn("No graphic card that supports required OpenGL features has been detected. The 3D map will be not be available");
	}
	ToolTipManager.sharedInstance().setInitialDelay(0);
	// init panels
	_statusPanel = new StatusPanel(_services);
	_replayPanel = new ReplayPanel(_services, _statusPanel);
	_controlPanel = new ControlPanel(_services, this, _replayPanel, Env.INSTANCE.isIs3dMap(), Env.INSTANCE.getMode());

	_split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
	_rightSplit = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
	_rightPanel = new JPanel(new BorderLayout());
	_rightPanel.add(_rightSplit, BorderLayout.CENTER);
	_rightPanel.add(_statusPanel, BorderLayout.SOUTH);
	_split.setRightComponent(_rightPanel);
	createRightView();
	createMap(false);
	add(_split, BorderLayout.CENTER);

	// add header
	add(_controlPanel, BorderLayout.NORTH);
	resizeSplit();
}
 
Example #9
Source File: Test6657026.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) throws InterruptedException {
    ToolTipManager manager = ToolTipManager.sharedInstance();
    if (DISMISS != manager.getDismissDelay()) {
        throw new Error("unexpected dismiss delay");
    }
    if (INITIAL != manager.getInitialDelay()) {
        throw new Error("unexpected initial delay");
    }
    if (RESHOW != manager.getReshowDelay()) {
        throw new Error("unexpected reshow delay");
    }
    manager.setDismissDelay(DISMISS + 1);
    manager.setInitialDelay(INITIAL + 1);
    manager.setReshowDelay(RESHOW + 1);

    ThreadGroup group = new ThreadGroup("$$$");
    Thread thread = new Thread(group, new Test6657026());
    thread.start();
    thread.join();
}
 
Example #10
Source File: ChartPanel.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Handles a 'mouse exited' event. This method resets the tooltip delays of
 * ToolTipManager.sharedInstance() to their
 * original values in effect before mouseEntered()
 *
 * @param e  the mouse event.
 */
public void mouseExited(MouseEvent e) {
    if (this.ownToolTipDelaysActive) {
        // restore original tooltip dealys
        ToolTipManager ttm = ToolTipManager.sharedInstance();
        ttm.setInitialDelay(this.originalToolTipInitialDelay);
        ttm.setReshowDelay(this.originalToolTipReshowDelay);
        ttm.setDismissDelay(this.originalToolTipDismissDelay);
        this.ownToolTipDelaysActive = false;
    }

    if (this.liveMouseHandler != null) {
        this.liveMouseHandler.mouseExited(e);
    }
    Iterator iterator = this.auxiliaryMouseHandlers.iterator();
    while (iterator.hasNext()) {
        AbstractMouseHandler h = (AbstractMouseHandler) iterator.next();
        h.mouseExited(e);
    }
}
 
Example #11
Source File: ChartPanel.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Handles a 'mouse entered' event. This method changes the tooltip delays
 * of ToolTipManager.sharedInstance() to the possibly different values set
 * for this chart panel.
 *
 * @param e  the mouse event.
 */
public void mouseEntered(MouseEvent e) {
    if (!this.ownToolTipDelaysActive) {
        ToolTipManager ttm = ToolTipManager.sharedInstance();

        this.originalToolTipInitialDelay = ttm.getInitialDelay();
        ttm.setInitialDelay(this.ownToolTipInitialDelay);

        this.originalToolTipReshowDelay = ttm.getReshowDelay();
        ttm.setReshowDelay(this.ownToolTipReshowDelay);

        this.originalToolTipDismissDelay = ttm.getDismissDelay();
        ttm.setDismissDelay(this.ownToolTipDismissDelay);

        this.ownToolTipDelaysActive = true;
    }

    if (this.liveMouseHandler != null) {
        this.liveMouseHandler.mouseEntered(e);
    }
    Iterator iterator = this.auxiliaryMouseHandlers.iterator();
    while (iterator.hasNext()) {
        AbstractMouseHandler h = (AbstractMouseHandler) iterator.next();
        h.mouseEntered(e);
    }
}
 
Example #12
Source File: Test6657026.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) throws InterruptedException {
    ToolTipManager manager = ToolTipManager.sharedInstance();
    if (DISMISS != manager.getDismissDelay()) {
        throw new Error("unexpected dismiss delay");
    }
    if (INITIAL != manager.getInitialDelay()) {
        throw new Error("unexpected initial delay");
    }
    if (RESHOW != manager.getReshowDelay()) {
        throw new Error("unexpected reshow delay");
    }
    manager.setDismissDelay(DISMISS + 1);
    manager.setInitialDelay(INITIAL + 1);
    manager.setReshowDelay(RESHOW + 1);

    ThreadGroup group = new ThreadGroup("$$$");
    Thread thread = new Thread(group, new Test6657026());
    thread.start();
    thread.join();
}
 
Example #13
Source File: ComponentDetailsProvider.java    From visualvm with GNU General Public License v2.0 6 votes vote down vote up
private void hoverChanged() {
    String toolTipText;
    if (hover != null) {                
        JComponent jc = hover instanceof JComponent ? (JComponent)hover : null;
        Object cn = jc == null ? null : jc.getClientProperty("className");
        String name = cn == null ? "" : cn.toString();
        
        toolTipText = name.isEmpty() ? null : name;
    } else {
        toolTipText = null;
    }
    // ToolTipManager doesn't like changing the tooltip from mouseMoved().
    // This is a workaround to hide the tip when needed and prevent NPEs.
    if (toolTipText == null) ToolTipManager.sharedInstance().mousePressed(null);
    glassPane.setToolTipText(toolTipText);
    repaint();
}
 
Example #14
Source File: IndicatorTextField.java    From scelight with Apache License 2.0 6 votes vote down vote up
/**
 * Creates a new {@link IndicatorTextField}.
 * 
 * @param text initial text to be set
 */
public IndicatorTextField( final String text ) {
	// Create a text field which shows the complete path in the tool tip.
	textField = new XTextField() {
		// Register this at the Tool tip manager.
		// Simply calling setToolTipText( "" ) does not work because my getToolTipText() always returns a non-null text,
		// and setToolTipText( "" ) only registers at the tool tip manager if previous tool tip is not null!
		{
			ToolTipManager.sharedInstance().registerComponent( this );
		}
		
		@Override
		public String getToolTipText() {
			return getText().isEmpty() ? null : getText();
		}
	};
	
	if ( text != null )
		textField.setText( text );
	addCenter( textField );
}
 
Example #15
Source File: AbstractViewTabDisplayerUI.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Override
public void uninstallUI(JComponent c) {
    super.uninstallUI(c);
    ToolTipManager.sharedInstance().unregisterComponent(displayer);
    displayer.removePropertyChangeListener (controller);
    dataModel.removeChangeListener(controller);
    dataModel.removeComplexListDataListener(controller);
    selectionModel.removeChangeListener(controller);
    displayer.removeMouseListener(controller);
    displayer.removeMouseMotionListener(controller);
    if (controlButtons != null) {
        displayer.remove(controlButtons);
        controlButtons = null;
    }
    layoutModel = null;
    selectionModel = null;
    dataModel = null;
    controller = null;
}
 
Example #16
Source File: Test6657026.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) throws InterruptedException {
    ToolTipManager manager = ToolTipManager.sharedInstance();
    if (DISMISS != manager.getDismissDelay()) {
        throw new Error("unexpected dismiss delay");
    }
    if (INITIAL != manager.getInitialDelay()) {
        throw new Error("unexpected initial delay");
    }
    if (RESHOW != manager.getReshowDelay()) {
        throw new Error("unexpected reshow delay");
    }
    manager.setDismissDelay(DISMISS + 1);
    manager.setInitialDelay(INITIAL + 1);
    manager.setReshowDelay(RESHOW + 1);

    ThreadGroup group = new ThreadGroup("$$$");
    Thread thread = new Thread(group, new Test6657026());
    thread.start();
    thread.join();
}
 
Example #17
Source File: Test6657026.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) throws InterruptedException {
    ToolTipManager manager = ToolTipManager.sharedInstance();
    if (DISMISS != manager.getDismissDelay()) {
        throw new Error("unexpected dismiss delay");
    }
    if (INITIAL != manager.getInitialDelay()) {
        throw new Error("unexpected initial delay");
    }
    if (RESHOW != manager.getReshowDelay()) {
        throw new Error("unexpected reshow delay");
    }
    manager.setDismissDelay(DISMISS + 1);
    manager.setInitialDelay(INITIAL + 1);
    manager.setReshowDelay(RESHOW + 1);

    ThreadGroup group = new ThreadGroup("$$$");
    Thread thread = new Thread(group, new Test6657026());
    thread.start();
    thread.join();
}
 
Example #18
Source File: Test6657026.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
public void run() {
    SunToolkit.createNewAppContext();
    ToolTipManager manager = ToolTipManager.sharedInstance();
    if (DISMISS != manager.getDismissDelay()) {
        throw new Error("shared dismiss delay");
    }
    if (INITIAL != manager.getInitialDelay()) {
        throw new Error("shared initial delay");
    }
    if (RESHOW != manager.getReshowDelay()) {
        throw new Error("shared reshow delay");
    }
}
 
Example #19
Source File: NamedSelectionTopComponent.java    From constellation with Apache License 2.0 5 votes vote down vote up
/**
 * Constructs a new <code>NamedSelectionTopComponent</code>.
 */
public NamedSelectionTopComponent() {
    initComponents();

    setName(Bundle.CTL_NamedSelectionTopComponent());
    setToolTipText(Bundle.HINT_NamedSelectionTopComponent());

    // Create label and container to show user when no active graph selected:
    panelNoGraph.setLayout(new BorderLayout());
    panelNoGraph.setName("panelNoGraph");
    lblNoGraph.setBackground(Color.WHITE);
    lblNoGraph.setForeground(Color.LIGHT_GRAY);
    lblNoGraph.setOpaque(true);
    lblNoGraph.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
    lblNoGraph.setVerticalAlignment(javax.swing.SwingConstants.CENTER);
    panelNoGraph.add(lblNoGraph, BorderLayout.CENTER);

    // Assign custom cell renderer:
    lstNamedSelections.setCellRenderer(new NamedSelectionCellRenderer());

    // Assign mouse and keyboard listeners:
    lstNamedSelections.addMouseListener(mouseListener);
    lstNamedSelections.addKeyListener(keyListener);

    // Context menu (popupmenu):
    lstNamedSelections.setComponentPopupMenu(popContext);

    // Register the list of selections for tooltips:
    ToolTipManager.sharedInstance().registerComponent(lstNamedSelections);

    // Set the list model to the list:
    final NamedSelectionListModel listModel = new NamedSelectionListModel();
    lstNamedSelections.setModel(listModel);

    // Start with nothing visible:
    toggleUI(false);
}
 
Example #20
Source File: Test6657026.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
public void run() {
    SunToolkit.createNewAppContext();
    ToolTipManager manager = ToolTipManager.sharedInstance();
    if (DISMISS != manager.getDismissDelay()) {
        throw new Error("shared dismiss delay");
    }
    if (INITIAL != manager.getInitialDelay()) {
        throw new Error("shared initial delay");
    }
    if (RESHOW != manager.getReshowDelay()) {
        throw new Error("shared reshow delay");
    }
}
 
Example #21
Source File: TreeList.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public TreeList(TreeListModel model) {
    super(model);
    setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    setFixedCellHeight(ROW_HEIGHT + INSETS_TOP + INSETS_BOTTOM + 2);
    setCellRenderer(renderer);
    setBackground(ColorManager.getDefault().getDefaultBackground());
    ToolTipManager.sharedInstance().registerComponent(this);
    addMouseListener(new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent e) {
            if (e.getClickCount() != 2 || e.isPopupTrigger() || e.isConsumed()) {
                return;
            }
            int index = locationToIndex(e.getPoint());
            if (index < 0 || index >= getModel().getSize()) {
                return;
            }
            Object value = getModel().getElementAt(index);
            if (value instanceof TreeListNode) {
                TreeListNode node = (TreeListNode) value;

                if (null != node && !node.isExpandable()) {
                    ActionListener al = node.getDefaultAction();
                    if (null != al) {
                        al.actionPerformed(new ActionEvent(e.getSource(), e.getID(), e.paramString()));
                    }
                } else if (null != node && node.isExpandable()) {
                    if (!node.isLoaded()) {
                        return;
                    }
                    node.setExpanded(!node.isExpanded());
                }
            }
        }
    });
}
 
Example #22
Source File: Test6657026.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
public void run() {
    SunToolkit.createNewAppContext();
    ToolTipManager manager = ToolTipManager.sharedInstance();
    if (DISMISS != manager.getDismissDelay()) {
        throw new Error("shared dismiss delay");
    }
    if (INITIAL != manager.getInitialDelay()) {
        throw new Error("shared initial delay");
    }
    if (RESHOW != manager.getReshowDelay()) {
        throw new Error("shared reshow delay");
    }
}
 
Example #23
Source File: GraphPanel.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private void updateTooltipText(List<ItemSelection> selectedItems) {
    if (!isTooltipShowing()) return;

    if (selectedItems.isEmpty()) {
        chart.setToolTipText(NO_DATA_TOOLTIP);
    } else {
        chart.setToolTipText(getTooltipText(selectedItems));
    }

    // A MouseEvent needs to be passed to the ToolTipManager to
    // immediately update the displayed tooltip
    MouseEvent e = new MouseEvent(chart, 0, 0, 0, mouseX, mouseY, 0, false);
    ToolTipManager.sharedInstance().mouseMoved(e);
}
 
Example #24
Source File: PreferencesDialog.java    From magarena with GNU General Public License v3.0 5 votes vote down vote up
public PreferencesDialog(final MagicFrame frame, final boolean isGamePlayMode) {

        super(frame, true);
        this.isGamePlayMode = isGamePlayMode;

        this.setTitle(MText.get(_S79));
        this.setSize(460, 530);
        this.setLocationRelativeTo(ScreenController.getFrame());
        this.setResizable(false);
        this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
        setUndecorated(true);
        ((JComponent) getContentPane()).setBorder(BorderFactory.createMatteBorder(0, 8, 8, 8, MagicStyle.getTheme().getColor(Theme.COLOR_TITLE_BACKGROUND)));

        this.frame = frame;

        generalPanel = new GeneralPanel(this);
        animationsPanel = new AnimationsPanel(this);
        gameImagesPanel = new GameplayImagesPanel(this);
        audioPanel = new AudioPanel(this);
        themesPanel = new ThemesPanel(this);

        hintLabel.setVerticalAlignment(SwingConstants.TOP);
        hintLabel.setFont(new Font("SansSerif", Font.ITALIC, 12));
        hintLabel.setVerticalTextPosition(SwingConstants.TOP);
        // hint label replaces tooltips.
        ToolTipManager.sharedInstance().setEnabled(false);

        getContentPane().setLayout(new MigLayout("flowy, insets 0, gapy 0"));
        getContentPane().add(getDialogCaptionLabel(), "w 100%, h 26!");
        getContentPane().add(getTabbedSettingsPane(), "w 10:100%, h 100%");
        getContentPane().add(hintLabel, "w 100%, h 76!, gapx 10 10");
        getContentPane().add(getActionButtonsPanel(), "w 100%, aligny bottom, pushy");

        setEscapeKeyAsCancelAction();
        addWindowListener(this);

        setVisible(true);
    }
 
Example #25
Source File: FabricMainWindow.java    From fabric-loader with Apache License 2.0 5 votes vote down vote up
private static JPanel createTreePanel(FabricStatusNode rootNode, FabricTreeWarningLevel minimumWarningLevel,
	IconSet iconSet) {
	JPanel panel = new JPanel();
	panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));

	TreeNode treeNode = new CustomTreeNode(null, rootNode, minimumWarningLevel);

	DefaultTreeModel model = new DefaultTreeModel(treeNode);
	JTree tree = new JTree(model);
	tree.setRootVisible(false);

	for (int row = 0; row < tree.getRowCount(); row++) {
		if (!tree.isVisible(tree.getPathForRow(row))) {
			continue;
		}

		CustomTreeNode node = ((CustomTreeNode) tree.getPathForRow(row).getLastPathComponent());

		if (node.node.expandByDefault || node.node.getMaximumWarningLevel().isAtLeast(FabricTreeWarningLevel.WARN)) {
			tree.expandRow(row);
		}
	}

	ToolTipManager.sharedInstance().registerComponent(tree);
	tree.setCellRenderer(new CustomTreeCellRenderer(iconSet));

	JScrollPane scrollPane = new JScrollPane(tree);
	panel.add(scrollPane);

	return panel;
}
 
Example #26
Source File: MultiChoiceComponent.java    From mzmine2 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Create the pane with a checkbox for each choice.
 *
 * @param theChoices the available choices.
 */
private CheckBoxPanel(final Object[] theChoices) {

  setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
  setOpaque(false);

  final int choiceCount = theChoices.length;
  checkBoxes = new JCheckBox[choiceCount];

  for (int i = 0; i < choiceCount; i++) {

    // Create a check box (inherit tooltip text.
    final JCheckBox checkBox = new JCheckBox(theChoices[i].toString()) {

      /**
       * 
       */
      private static final long serialVersionUID = 1L;

      @Override
      public String getToolTipText() {

        return MultiChoiceComponent.this.getToolTipText();
      }
    };
    checkBox.addItemListener(e -> handleItemChanged());
    checkBox.setFont(CHECKBOX_FONT);
    checkBox.setOpaque(false);
    add(checkBox);
    ToolTipManager.sharedInstance().registerComponent(checkBox);
    checkBoxes[i] = checkBox;
  }
}
 
Example #27
Source File: ChartPanel.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Switches the display of tooltips for the panel on or off.  Note that
 * tooltips can only be displayed if the chart has been configured to
 * generate tooltip items.
 *
 * @param flag  <code>true</code> to enable tooltips, <code>false</code> to
 *              disable tooltips.
 */
public void setDisplayToolTips(boolean flag) {
    if (flag) {
        ToolTipManager.sharedInstance().registerComponent(this);
    }
    else {
        ToolTipManager.sharedInstance().unregisterComponent(this);
    }
}
 
Example #28
Source File: ChartPanel.java    From ECG-Viewer with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Switches the display of tooltips for the panel on or off.  Note that
 * tooltips can only be displayed if the chart has been configured to
 * generate tooltip items.
 *
 * @param flag  <code>true</code> to enable tooltips, <code>false</code> to
 *              disable tooltips.
 */
public void setDisplayToolTips(boolean flag) {
    if (flag) {
        ToolTipManager.sharedInstance().registerComponent(this);
    }
    else {
        ToolTipManager.sharedInstance().unregisterComponent(this);
    }
}
 
Example #29
Source File: ProjectExplorer.java    From Logisim with GNU General Public License v3.0 5 votes vote down vote up
public ProjectExplorer(Project proj) {
	super();
	this.proj = proj;

	setModel(model);
	setRootVisible(true);
	addMouseListener(myListener);
	ToolTipManager.sharedInstance().registerComponent(this);

	MySelectionModel selector = new MySelectionModel();
	selector.setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
	setSelectionModel(selector);
	setCellRenderer(renderer);
	JTreeUtil.configureDragAndDrop(this, new DragController());
	addTreeSelectionListener(myListener);

	InputMap imap = getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
	imap.put(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0), deleteAction);
	ActionMap amap = getActionMap();
	amap.put(deleteAction, deleteAction);

	proj.addProjectListener(myListener);
	proj.addLibraryListener(myListener);
	AppPreferences.GATE_SHAPE.addPropertyChangeListener(myListener);
	myListener.setFile(proj.getLogisimFile());
	LocaleManager.addLocaleListener(this);
}
 
Example #30
Source File: AbstractChartPanel.java    From rapidminer-studio with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * Handles a 'mouse exited' event. This method resets the tooltip delays of
 * ToolTipManager.sharedInstance() to their original values in effect before mouseEntered()
 * 
 * @param e
 *            the mouse event.
 */

@Override
public void mouseExited(MouseEvent e) {
	if (this.ownToolTipDelaysActive) {
		// restore original tooltip dealys
		ToolTipManager ttm = ToolTipManager.sharedInstance();
		ttm.setInitialDelay(this.originalToolTipInitialDelay);
		ttm.setReshowDelay(this.originalToolTipReshowDelay);
		ttm.setDismissDelay(this.originalToolTipDismissDelay);
		this.ownToolTipDelaysActive = false;
	}
}