Java Code Examples for javax.swing.JToolTip#setTipText()
The following examples show how to use
javax.swing.JToolTip#setTipText() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TruncatedTextListingHover.java From ghidra with Apache License 2.0 | 6 votes |
@Override public JComponent getHoverComponent(Program program, ProgramLocation programLocation, FieldLocation fieldLocation, Field field) { if (!enabled || programLocation == null || !(field instanceof ListingTextField)) { return null; } if (((ListingTextField) field).isClipped()) { String text = field.getTextWithLineSeparators(); String convertToHtml = HTMLUtilities.toLiteralHTMLForTooltip(text); JToolTip toolTip = new JToolTip(); toolTip.setTipText(convertToHtml); return toolTip; } return null; }
Example 2
Source File: AbstractHover.java From ghidra with Apache License 2.0 | 5 votes |
protected JComponent createTooltipComponent(String content) { if (!isValidTooltipContent(content)) { return null; } JToolTip tt = new JToolTip(); tt.setTipText(content); return tt; }
Example 3
Source File: FlashingIcon.java From netbeans with Apache License 2.0 | 5 votes |
@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; }
Example 4
Source File: FlashingIcon.java From netbeans with Apache License 2.0 | 5 votes |
@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; }
Example 5
Source File: TableRendererTest.java From netbeans with Apache License 2.0 | 5 votes |
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()); }
Example 6
Source File: LuceneDataStoreSearchGUI.java From gate-core with GNU Lesser General Public License v3.0 | 5 votes |
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); } }
Example 7
Source File: LuceneDataStoreSearchGUI.java From gate-core with GNU Lesser General Public License v3.0 | 5 votes |
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); } }
Example 8
Source File: CfgPropsDocAndTooltipQuery.java From nb-springboot with Apache License 2.0 | 5 votes |
@Override protected void query(CompletionResultSet completionResultSet, Document document, int caretOffset) { final StyledDocument styDoc = (StyledDocument) document; Element lineElement = styDoc.getParagraphElement(caretOffset); int lineStartOffset = lineElement.getStartOffset(); int lineEndOffset = lineElement.getEndOffset(); try { String line = styDoc.getText(lineStartOffset, lineEndOffset - lineStartOffset); if (line.endsWith("\n")) { line = line.substring(0, line.length() - 1); } if (showTooltip) { logger.log(FINER, "Tooltip on: {0}", line); } else { logger.log(FINER, "Documentation on: {0}", line); } if (!line.contains("#")) { //property name extraction from line Matcher matcher = PATTERN_PROP_NAME.matcher(line); if (matcher.matches()) { String propPrefix = matcher.group(1); ConfigurationMetadataProperty propMeta = sbs.getPropertyMetadata(propPrefix); if (propMeta != null) { if (showTooltip) { final JToolTip toolTip = new JToolTip(); toolTip.setTipText(Utils.shortenJavaType(propMeta.getType())); completionResultSet.setToolTip(toolTip); } else { completionResultSet.setDocumentation(new CfgPropCompletionDocumentation(propMeta)); } } } } } catch (BadLocationException ex) { Exceptions.printStackTrace(ex); } completionResultSet.finish(); }
Example 9
Source File: FlashingIcon.java From visualvm with GNU General Public License v2.0 | 5 votes |
@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; }
Example 10
Source File: IOLocationTileList.java From pumpernickel with MIT License | 5 votes |
@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); }
Example 11
Source File: MapUnitTooltipManager.java From triplea with GNU General Public License v3.0 | 5 votes |
@Override public void actionPerformed(final ActionEvent e) { if (text != null && text.length() > 0) { final Point currentPoint = MouseInfo.getPointerInfo().getLocation(); if (isPointWithinParentBounds(currentPoint)) { final PopupFactory popupFactory = PopupFactory.getSharedInstance(); final JToolTip info = new JToolTip(); info.setTipText("<html>" + text + "</html>"); popup = popupFactory.getPopup(parent, info, currentPoint.x + 20, currentPoint.y - 20); popup.show(); } } }
Example 12
Source File: AbstractPatchedTransferHandler.java From rapidminer-studio with GNU Affero General Public License v3.0 | 4 votes |
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(); } }