⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mouseoverhintmanager.java

📁 JRemoteControl is a simple Java&#8482 driven bluetooth remote control.It allows you to initiate virt
💻 JAVA
字号:
/* * http://articles.techrepublic.com.com/5100-3513-5185994.html# */package fildiv.jremcntl.server.gui.util.swing;import java.awt.*;import java.awt.event.*;import java.util.*;import javax.swing.*;import javax.swing.table.*;public class MouseOverHintManager implements MouseListener {	private Map hintMap;	private JLabel hintLabel;	public MouseOverHintManager(JLabel hintLabel) {		hintMap = new WeakHashMap();		this.hintLabel = hintLabel;	}	public void addHintFor(Component comp, String hintText) {		hintMap.put(comp, hintText);	}	public void enableHints(Component comp) {		comp.addMouseListener(this);		if (comp instanceof Container) {			Component[] components = ((Container) comp).getComponents();			for (int i = 0; i < components.length; i++)				enableHints(components[i]);		}		if (comp instanceof MenuElement) {			MenuElement[] elements = ((MenuElement) comp).getSubElements();			for (int i = 0; i < elements.length; i++)				enableHints(elements[i].getComponent());		}	}	private String getHintFor(Component comp) {		String hint = (String) hintMap.get(comp);		if (hint == null) {			if (comp instanceof JLabel)				hint = (String) hintMap.get(((JLabel) comp).getLabelFor());			else if (comp instanceof JTableHeader)				hint = (String) hintMap.get(((JTableHeader) comp).getTable());			else if (comp instanceof AbstractButton) {								AbstractButton b = (AbstractButton) comp;								Action act = b.getAction();								if (act != null)					hint = (String) act.getValue(Action.LONG_DESCRIPTION);						} else if (comp instanceof JMenuItem) {								JMenuItem item = (JMenuItem) comp;				Action act = item.getAction();				if (act != null)					hint = (String) act.getValue(Action.LONG_DESCRIPTION);			}		}		return hint;	}	public void mouseEntered(MouseEvent e) {		Component comp = (Component) e.getSource();		String hint;		do {			hint = getHintFor(comp);			comp = comp.getParent();		} while ((hint == null) && (comp != null));		if (hint != null)			hintLabel.setText(hint);	}	public void mouseExited(MouseEvent e) {		hintLabel.setText("Ready ...");	}	public void mouseClicked(MouseEvent e) {	}	public void mousePressed(MouseEvent e) {	}	public void mouseReleased(MouseEvent e) {	}}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -