本文整理汇总了Java中javax.swing.JLabel.getToolTipText方法的典型用法代码示例。如果您正苦于以下问题:Java JLabel.getToolTipText方法的具体用法?Java JLabel.getToolTipText怎么用?Java JLabel.getToolTipText使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.JLabel
的用法示例。
在下文中一共展示了JLabel.getToolTipText方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: mouseEntered
import javax.swing.JLabel; //导入方法依赖的package包/类
@Override
public void mouseEntered(MouseEvent e) {
dismissDelay = toolTipManager.getDismissDelay();
initialDelay = toolTipManager.getInitialDelay();
reshowDelay = toolTipManager.getReshowDelay();
enabled = toolTipManager.isEnabled();
Component component = e.getComponent();
if(feature != null && !isTooltipSet && component instanceof JLabel) {
isTooltipSet = true;
JLabel label = (JLabel)component;
String toolTip = label.getToolTipText();
toolTip =
(toolTip == null || toolTip.equals("")) ? "" : toolTip
.replaceAll("</?html>", "") + "<br>";
toolTip = "<html>" + toolTip + "Right click to get statistics.</html>";
label.setToolTipText(toolTip);
}
// make the tooltip indefinitely shown when the mouse is over
toolTipManager.setDismissDelay(Integer.MAX_VALUE);
toolTipManager.setInitialDelay(0);
toolTipManager.setReshowDelay(0);
toolTipManager.setEnabled(true);
}
示例2: addStatistics
import javax.swing.JLabel; //导入方法依赖的package包/类
private void addStatistics(String kind, int count, int numRow,
final MouseEvent e) {
JLabel label = (JLabel)e.getComponent();
if(!label.getToolTipText().contains(kind)) {
// add the statistics to the tooltip
String toolTip = label.getToolTipText();
toolTip = toolTip.replaceAll("</?html>", "");
toolTip = kind + " = " + count + "<br>" + toolTip;
toolTip = "<html>" + toolTip + "</html>";
label.setToolTipText(toolTip);
}
if(bottomSplitPane.getDividerLocation()
/ bottomSplitPane.getSize().getWidth() < 0.90) {
// select the row in the statistics table
statisticsTabbedPane.setSelectedIndex(1);
oneRowStatisticsTable.setRowSelectionInterval(numRow, numRow);
oneRowStatisticsTable.scrollRectToVisible(oneRowStatisticsTable
.getCellRect(numRow, 0, true));
} else {
// display a tooltip
JToolTip tip = label.createToolTip();
tip.setTipText(kind + " = " + count);
PopupFactory popupFactory = PopupFactory.getSharedInstance();
final Popup tipWindow =
popupFactory.getPopup(label, tip, e.getX()
+ e.getComponent().getLocationOnScreen().x, e.getY()
+ e.getComponent().getLocationOnScreen().y);
tipWindow.show();
Date timeToRun = new Date(System.currentTimeMillis() + 2000);
Timer timer = new Timer("Annic statistics hide tooltip timer", true);
timer.schedule(new TimerTask() {
@Override
public void run() {
// hide the tooltip after 2 seconds
tipWindow.hide();
}
}, timeToRun);
}
}