本文整理匯總了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);
}
}