當前位置: 首頁>>代碼示例>>Java>>正文


Java JToolTip.setTipText方法代碼示例

本文整理匯總了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
    }
}
 
開發者ID:limagiran,項目名稱:hearthstone,代碼行數:20,代碼來源:DeckBack.java

示例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
    }
}
 
開發者ID:limagiran,項目名稱:hearthstone,代碼行數:20,代碼來源:MaoBack.java

示例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;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:12,代碼來源:FlashingIcon.java

示例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());
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:39,代碼來源:TableRendererTest.java

示例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;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:12,代碼來源:FlashingIcon.java

示例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();
        }
    });
}
 
開發者ID:ArturWisniewski,項目名稱:NB-Thymeleaf-Code-Completion,代碼行數:19,代碼來源:ThymeleafCompletionItem.java

示例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);
  }
}
 
開發者ID:GateNLP,項目名稱:gate-core,代碼行數:40,代碼來源:LuceneDataStoreSearchGUI.java

示例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();
        }
    });
}
 
開發者ID:AlexFalappa,項目名稱:nb-springboot,代碼行數:13,代碼來源:CfgPropCompletionItem.java

示例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);
}
 
開發者ID:mickleness,項目名稱:pumpernickel,代碼行數:28,代碼來源:IOLocationTileList.java

示例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);
}
 
開發者ID:valsr,項目名稱:SweetHome3D,代碼行數:14,代碼來源:PlanComponent.java

示例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();
	}
}
 
開發者ID:transwarpio,項目名稱:rapidminer,代碼行數:46,代碼來源:AbstractPatchedTransferHandler.java

示例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();
		}
	}
 
開發者ID:rapidminer,項目名稱:rapidminer-5,代碼行數:46,代碼來源:AbstractPatchedTransferHandler.java

示例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("&nbsp ");
        }
        else {
          tipBuilder.append(JDOMUtil.legalizeText(each));
        }
      }
    }

    tooltip.setTipText(UIUtil.toHtml(tipBuilder.toString(), 0));
  }

  tooltip.setBorder(null);

  return tooltip;
}
 
開發者ID:consulo,項目名稱:consulo-java,代碼行數:43,代碼來源:DebuggerTreeBase.java


注:本文中的javax.swing.JToolTip.setTipText方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。