本文整理匯總了Java中javax.swing.JToolTip.setTipText方法的典型用法代碼示例。如果您正苦於以下問題:Java JToolTip.setTipText方法的具體用法?Java JToolTip.setTipText怎麽用?Java JToolTip.setTipText使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.swing.JToolTip
的用法示例。
在下文中一共展示了JToolTip.setTipText方法的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: showToolTip
import javax.swing.JToolTip; //導入方法依賴的package包/類
private void showToolTip(boolean flag) {
try {
if (flag) {
int qtd = heroi.getDeck().size();
String txt = (qtd == 0 ? "Nenhum card" : qtd == 1
? "1 card" : qtd + " cards");
Point p = getLocationOnScreen();
JToolTip tip = createToolTip();
tip.setTipText(txt);
PopupFactory popupFactory = PopupFactory.getSharedInstance();
tooltip = popupFactory.getPopup(this, tip, p.x + 10, p.y + 10);
tooltip.show();
} else {
tooltip.hide();
}
} catch (Exception ex) {
//ignorar
}
}
示例2: showToolTip
import javax.swing.JToolTip; //導入方法依賴的package包/類
private void showToolTip(boolean flag) {
try {
if (flag) {
int qtd = heroi.getMao().size();
String txt = (qtd == 0 ? "Nenhum card" : qtd == 1
? "1 card" : qtd + " cards");
Point p = getLocationOnScreen();
JToolTip tip = createToolTip();
tip.setTipText(txt);
PopupFactory popupFactory = PopupFactory.getSharedInstance();
tooltip = popupFactory.getPopup(this, tip, p.x + 10, p.y + 10);
tooltip.show();
} else {
tooltip.hide();
}
} catch (Exception ex) {
//ignorar
}
}
示例3: getToolTipLocation
import javax.swing.JToolTip; //導入方法依賴的package包/類
@Override
public Point getToolTipLocation(MouseEvent event) {
JToolTip tip = createToolTip();
tip.setTipText(getToolTipText());
Dimension d = tip.getPreferredSize();
Point retValue = new Point(getWidth() - d.width, -d.height);
return retValue;
}
示例4: testTooltip
import javax.swing.JToolTip; //導入方法依賴的package包/類
public void testTooltip() {
setUpModel();
JTable t = ot.treeTable.getTable();
ot.revalidate();
javax.swing.JFrame f = new javax.swing.JFrame();
f.setLayout(new BorderLayout());
f.add(ot, BorderLayout.CENTER);
f.setSize(600, 500);
f.setVisible(true);
//while (f.isVisible()) {
try {
Thread.sleep(333);
} catch (InterruptedException ex) {
Exceptions.printStackTrace(ex);
}
//}
MouseEvent event = getMouseClickAt(t, 0, 0);
String tipText = t.getToolTipText(event);
JToolTip tip = t.createToolTip();
tip.setTipText(tipText);
assertTrue("Bad ToolTip class: "+tip, tip instanceof RendererComponent.ToolTipComponent);
assertEquals("ToolTip for Renderer of 0:DN", tip.getTipText());
event = getMouseClickAt(t, 1, 1);
tipText = t.getToolTipText(event);
tip = t.createToolTip();
tip.setTipText(tipText);
assertFalse("Bad ToolTip class: "+tip, tip instanceof RendererComponent.ToolTipComponent);
event = getMouseClickAt(t, 2, 2);
tipText = t.getToolTipText(event);
tip = t.createToolTip();
tip.setTipText(tipText);
assertTrue("Bad ToolTip class: "+tip, tip instanceof RendererComponent.ToolTipComponent);
assertEquals("ToolTip for Renderer of 2:col2", tip.getTipText());
}
示例5: getToolTipLocation
import javax.swing.JToolTip; //導入方法依賴的package包/類
@Override
public Point getToolTipLocation( MouseEvent event ) {
JToolTip tip = createToolTip();
tip.setTipText( getToolTipText() );
Dimension d = tip.getPreferredSize();
Point retValue = new Point( getWidth()-d.width, -d.height );
return retValue;
}
示例6: createToolTipTask
import javax.swing.JToolTip; //導入方法依賴的package包/類
/**
* Returns a task used to obtain a tooltip hint associated with the item if
* there is any.
*
* @return CompletionTask
*/
@Override
public CompletionTask createToolTipTask() {
return new AsyncCompletionTask(new AsyncCompletionQuery() {
@Override
protected void query(CompletionResultSet completionResultSet, Document document, int i) {
JToolTip toolTip = new JToolTip();
toolTip.setTipText("Press Enter to insert \"" + text + "\"");
completionResultSet.setToolTip(toolTip);
completionResultSet.finish();
}
});
}
示例7: addStatistics
import javax.swing.JToolTip; //導入方法依賴的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);
}
}
示例8: createToolTipTask
import javax.swing.JToolTip; //導入方法依賴的package包/類
@Override
public CompletionTask createToolTipTask() {
return new AsyncCompletionTask(new AsyncCompletionQuery() {
@Override
protected void query(CompletionResultSet completionResultSet, Document document, int i) {
JToolTip toolTip = new JToolTip();
toolTip.setTipText("Press Enter to insert \"" + getText() + "\"");
completionResultSet.setToolTip(toolTip);
completionResultSet.finish();
}
});
}
示例9: getToolTipLocation
import javax.swing.JToolTip; //導入方法依賴的package包/類
@Override
public Point getToolTipLocation(MouseEvent event) {
if(event != null) {
Point p = event.getPoint();
int index = locationToIndex(p);
ListCellRenderer r = getCellRenderer();
Rectangle cellBounds;
if (index != -1 && (r instanceof BasicTileCellRenderer) && (cellBounds =
getCellBounds(index, index)) != null &&
cellBounds.contains(p.x, p.y)) {
String text = getToolTipText(event);
JToolTip tip = new JToolTip();
tip.setTipText(text);
Dimension tipSize = tip.getPreferredSize();
BasicTileCellRenderer btcr = (BasicTileCellRenderer)r;
int yOffset = cellBounds.height/2;
if(btcr.thumbnail.getUI() instanceof ThumbnailLabelUI) {
ThumbnailLabelUI ui = (ThumbnailLabelUI)btcr.thumbnail.getUI();
yOffset = ui.getTextRect().y;
}
return new Point(cellBounds.x+cellBounds.width/2-tipSize.width/2, cellBounds.y+yOffset);
}
}
return super.getToolTipLocation(event);
}
示例10: setToolTipFeedback
import javax.swing.JToolTip; //導入方法依賴的package包/類
/**
* Sets tool tip text displayed as feedback.
* @param toolTipFeedback the text displayed in the tool tip
* or <code>null</code> to make tool tip disappear.
*/
public void setToolTipFeedback(String toolTipFeedback, float x, float y)
{
stopToolTipPropertiesEdition();
JToolTip toolTip = getToolTip();
// Change tool tip text
toolTip.setTipText(toolTipFeedback);
showToolTipComponentAt(toolTip, x, y);
}
示例11: showPopupAtMousePosition
import javax.swing.JToolTip; //導入方法依賴的package包/類
private void showPopupAtMousePosition() {
// StaticDebug.debug("DND POPUP: Show popup at Mouse position");
// get mouse location
Point screenLocation = MouseInfo.getPointerInfo().getLocation();
screenLocation.x += 26;
screenLocation.y += 10;
// if tooltip is shown
if (tipWindow != null) {
// StaticDebug.debug("DND POPUP: Popup is already shown");
// check if mouse has moved
if (mouseX != screenLocation.x || mouseY != screenLocation.y) {
// StaticDebug.debug("DND POPUP: old position x = "+mouseX);
// StaticDebug.debug("DND POPUP: old position y = "+mouseY);
// StaticDebug.debug("DND POPUP: new position x = "+screenLocation.x);
// StaticDebug.debug("DND POPUP: new position y = "+screenLocation.y);
// StaticDebug.debug("DND POPUP: Mouse position has changed.. hide popup first");
// hide tooltip
hideDropDeniedTooltip();
} else {
// StaticDebug.debug("DND POPUP: Restart hide timer to prevent popup from being hidden.");
// otherwise restart hide timer
hideTimer.restart();
return;
}
}
Point componentLocation = (Point) screenLocation.clone();
SwingUtilities.convertPointFromScreen(componentLocation, popupSource);
if (tipWindow == null && popupSource.contains(componentLocation)) {
// StaticDebug.debug("DND POPUP: Mouse is inside popupSource and popup is not shown");
JToolTip tip = popupSource.createToolTip();
tip.setTipText(reason);
PopupFactory popupFactory = PopupFactory.getSharedInstance();
mouseX = screenLocation.x;
mouseY = screenLocation.y;
// StaticDebug.debug("DND POPUP: show popup at "+mouseX+","+mouseY+" and start hide timer");
tipWindow = popupFactory.getPopup(popupSource, tip, mouseX, mouseY);
tipWindow.show();
hideTimer.restart();
}
}
示例12: showPopupAtMousePosition
import javax.swing.JToolTip; //導入方法依賴的package包/類
private void showPopupAtMousePosition() {
// StaticDebug.debug("DND POPUP: Show popup at Mouse position");
// get mouse location
Point screenLocation = MouseInfo.getPointerInfo().getLocation();
screenLocation.x += 26;
screenLocation.y += 10;
// if tooltip is shown
if (tipWindow != null) {
// StaticDebug.debug("DND POPUP: Popup is already shown");
// check if mouse has moved
if (mouseX != screenLocation.x || mouseY != screenLocation.y) {
// StaticDebug.debug("DND POPUP: old position x = "+mouseX);
// StaticDebug.debug("DND POPUP: old position y = "+mouseY);
// StaticDebug.debug("DND POPUP: new position x = "+screenLocation.x);
// StaticDebug.debug("DND POPUP: new position y = "+screenLocation.y);
// StaticDebug.debug("DND POPUP: Mouse position has changed.. hide popup first");
// hide tooltip
hideDropDeniedTooltip();
} else {
// StaticDebug.debug("DND POPUP: Restart hide timer to prevent popup from being hidden.");
// otherwise restart hide timer
hideTimer.restart();
return;
}
}
Point componentLocation = (Point) screenLocation.clone();
SwingUtilities.convertPointFromScreen(componentLocation, popupSource);
if (tipWindow == null && popupSource.contains(componentLocation)) {
// StaticDebug.debug("DND POPUP: Mouse is inside popupSource and popup is not shown");
JToolTip tip = popupSource.createToolTip();
tip.setTipText(reason);
PopupFactory popupFactory = PopupFactory.getSharedInstance();
mouseX = screenLocation.x;
mouseY = screenLocation.y;
// StaticDebug.debug("DND POPUP: show popup at "+mouseX+","+mouseY+" and start hide timer");
tipWindow = popupFactory.getPopup(popupSource, tip, mouseX, mouseY);
tipWindow.show();
hideTimer.restart();
}
}
示例13: createTipContent
import javax.swing.JToolTip; //導入方法依賴的package包/類
private JComponent createTipContent(String tipText, DebuggerTreeNodeImpl node) {
final JToolTip tooltip = new JToolTip();
if (tipText == null) {
tooltip.setTipText(tipText);
}
else {
Dimension rootSize = getVisibleRect().getSize();
Insets borderInsets = tooltip.getBorder().getBorderInsets(tooltip);
rootSize.width -= (borderInsets.left + borderInsets.right) * 2;
rootSize.height -= (borderInsets.top + borderInsets.bottom) * 2;
@NonNls StringBuilder tipBuilder = new StringBuilder();
final String markupText = node.getMarkupTooltipText();
if (markupText != null) {
tipBuilder.append(markupText);
}
if (!tipText.isEmpty()) {
final StringTokenizer tokenizer = new StringTokenizer(tipText, "\n ", true);
while (tokenizer.hasMoreElements()) {
final String each = tokenizer.nextElement();
if ("\n".equals(each)) {
tipBuilder.append("<br>");
}
else if (" ".equals(each)) {
tipBuilder.append("  ");
}
else {
tipBuilder.append(JDOMUtil.legalizeText(each));
}
}
}
tooltip.setTipText(UIUtil.toHtml(tipBuilder.toString(), 0));
}
tooltip.setBorder(null);
return tooltip;
}