类javax.swing.ToolTipManager源码实例Demo

下面列出了怎么用javax.swing.ToolTipManager的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: jdk8u-dev-jdk   文件: Test6657026.java
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();
}
 
@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();
    }
}
 
源代码3 项目: openstock   文件: ChartPanel.java
/**
 * 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;
    }
}
 
源代码4 项目: TencentKona-8   文件: Test6657026.java
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();
}
 
源代码5 项目: astor   文件: ChartPanel.java
/**
 * 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);
    }
}
 
源代码6 项目: openjdk-8   文件: Test6657026.java
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();
}
 
源代码7 项目: visualvm   文件: ComponentDetailsProvider.java
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();
}
 
源代码8 项目: scelight   文件: IndicatorTextField.java
/**
 * 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 );
}
 
源代码9 项目: seaglass   文件: SeaGlassDesktopIconUI.java
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);
}
 
源代码10 项目: netbeans   文件: AbstractViewTabDisplayerUI.java
@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;
}
 
源代码11 项目: astor   文件: ChartPanel.java
/**
 * 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);
    }
}
 
源代码12 项目: openjdk-jdk8u-backup   文件: Test6657026.java
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();
}
 
源代码13 项目: jdk8u-jdk   文件: Test6657026.java
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();
}
 
源代码14 项目: openvisualtraceroute   文件: MainPanel.java
/**
 * 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();
}
 
源代码15 项目: hottub   文件: Test6657026.java
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();
}
 
源代码16 项目: openjdk-8-source   文件: Test6657026.java
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();
}
 
源代码17 项目: constellation   文件: NamedSelectionTopComponent.java
/**
 * 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);
}
 
源代码18 项目: constellation   文件: Installer.java
@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);
}
 
源代码19 项目: openstock   文件: ChartPanel.java
/**
 * 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;
    }
}
 
private void configurePlantOverview(PlantOverviewApplicationConfiguration configuration) {
  Locale.setDefault(Locale.forLanguageTag(configuration.locale()));

  try {
    UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
  }
  catch (ClassNotFoundException | InstantiationException | IllegalAccessException
             | UnsupportedLookAndFeelException ex) {
    LOG.warn("Could not set look-and-feel", ex);
  }
  // Show tooltips for 30 seconds (Default: 4 sec)
  ToolTipManager.sharedInstance().setDismissDelay(30 * 1000);
}
 
源代码21 项目: scelight   文件: Link.java
/**
 * Creates a new {@link Link} which forwards mouse click events to the specified {@link Consumer} and opens the specified URL in the user's default browser
 * when clicked.
 * 
 * @param text text of the link
 * @param url {@link URL} to be opened when clicked
 * @param consumer consumer to be called when clicked
 */
public Link( final String text, final URL url, final Consumer< MouseEvent > consumer ) {
	setText( text );
	setUrl( url );
	
	this.consumer = consumer;
	
	setCursor( Cursor.getPredefinedCursor( Cursor.HAND_CURSOR ) );
	
	addMouseListener( new MouseAdapter() {
		@Override
		public void mousePressed( final MouseEvent event ) {
			if ( !isEnabled() )
				return;
			
			// Note: Link.this.consumer and Link.this.url is used
			// because these can be changed later (so we definitely don't want to refer to the local variable here!)
			if ( Link.this.consumer != null )
				Link.this.consumer.consume( event );
			if ( Link.this.url != null )
				LEnv.UTILS_IMPL.get().showURLInBrowser( Link.this.url );
		}
	} );
	
	// 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 );
}
 
源代码22 项目: blog-codes   文件: mxGraphComponent.java
/**
 * 
 * @param enabled
 */
public void setToolTips(boolean enabled)
{
	if (enabled)
	{
		ToolTipManager.sharedInstance().registerComponent(graphControl);
	}
	else
	{
		ToolTipManager.sharedInstance().unregisterComponent(graphControl);
	}
}
 
源代码23 项目: bigtable-sql   文件: ObjectTree.java
/**
 * Component has been added to its parent.
 */
public void addNotify()
{
	super.addNotify();
	// Register so that we can display different tooltips depending
	// which entry in list mouse is over.
	ToolTipManager.sharedInstance().registerComponent(this);
}
 
源代码24 项目: dragonwell8_jdk   文件: Test6657026.java
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");
    }
}
 
源代码25 项目: SproutLife   文件: PanelController.java
private void initComponents() {
    ToolTipManager.sharedInstance().setInitialDelay(0);
    gameFrame.setVisible(true);
    getGameToolbar().getZoomSlider().setValue(-4);
    getBoardSizeHandler().updateZoomValue(-4);
    getBoardSizeHandler().updateBoardSizeFromImageSize(getScrollPanel().getViewportSize());
    getImageManager().setBackgroundColor(new Color(160,160,160));

    initSeedTypeComboBox();

    initStatsPanel();

    loadTipText();               
}
 
源代码26 项目: visualvm   文件: GraphPanel.java
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);
}
 
源代码27 项目: jdk8u60   文件: Test6657026.java
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");
    }
}
 
源代码28 项目: opt4j   文件: DefaultModulesPanel.java
@Override
public void startup() {

	tree = new MyTree(root);
	tree.setToggleClickCount(1000); // don't expand on double click hack
	tree.addMouseListener(mouseListener);
	tree.setCellRenderer(new TreeCellRenderer());
	tree.setSelectionModel(null);

	ToolTipManager.sharedInstance().registerComponent(tree);

	JScrollPane scroll = new JScrollPane(tree, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,
			ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);

	setLayout(new BorderLayout());
	add(scroll, BorderLayout.CENTER);

	Thread thread = new Thread() {
		@Override
		public void run() {
			try {
				populateTree();
			} catch (RejectedExecutionException e) {
			}
		}
	};
	thread.setPriority(Thread.MIN_PRIORITY);
	thread.start();
}
 
源代码29 项目: SIMVA-SoS   文件: ChartPanel.java
/**
 * 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);
    }
}
 
源代码30 项目: xyTalk-pc   文件: ConfigPanel.java
private void initComponents()
{
    infoLabel = new JLabel("待开发...");
    button = new RCButton("设置", Colors.MAIN_COLOR, Colors.MAIN_COLOR_DARKER, Colors.MAIN_COLOR_DARKER);
    button.setPreferredSize(new Dimension(150, 35));
    ToolTipManager.sharedInstance().setDismissDelay(10000);
    button.setToolTipText("");
}
 
 类所在包
 同包方法