List of utility methods to do Swing Tooltip
void | addClickTipEffect(final JComponent component) add Click Tip Effect component.setForeground(new java.awt.Color(51, 51, 255)); component.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR)); component.addMouseListener(new java.awt.event.MouseAdapter() { @Override public void mouseEntered(MouseEvent e) { component.setOpaque(true); component.setBackground(new java.awt.Color(51, 51, 255)); component.setForeground(new java.awt.Color(255, 255, 255)); ... |
JComponent | createMarker(int span, String tooltip) create Marker JLabel marker = new JLabel(MARKER_LABEL); marker.setName(MARKER_NAME); marker.setHorizontalAlignment(JLabel.CENTER); marker.setOpaque(true); marker.setBackground(Color.RED); marker.setToolTipText(tooltip); return marker; |
JTextField | createNumericInput(final String tooltip) creates a JTextField. NumberFormat integerFormat = NumberFormat.getIntegerInstance(); integerFormat.setGroupingUsed(false); integerFormat.setParseIntegerOnly(true); final JTextField urlInput = new JTextField(); urlInput.setToolTipText(tooltip); urlInput.setDocument(new PlainDocument() { @Override public void insertString(final int offset, final String input, final AttributeSet a) ... |
void | displayTooltip(JComponent component) Forces the display of a component tooltop by sending it a CTRL-F1 key event. component.dispatchEvent(new KeyEvent(component, KeyEvent.KEY_PRESSED, 0, KeyEvent.CTRL_MASK, KeyEvent.VK_F1,
KeyEvent.CHAR_UNDEFINED));
|
void | hideToolTip(JComponent c) hide Tool Tip try { Method hideMethod = ToolTipManager.class.getDeclaredMethod("hide", JComponent.class); hideMethod.setAccessible(true); hideMethod.invoke(ToolTipManager.sharedInstance(), c); } catch (Exception e) { throw new RuntimeException(e); |
int | performMultipleReplacements(final Document theDocument, final String theRegexToSearch, final String theReplacement) Performs as many replacements as possible of pattern regex in document, starting at document index theStart. return performMultipleReplacements(theDocument, theRegexToSearch, theReplacement, 0);
|
void | setLongerTooltips() (re-)shows tooltips earlier (10 milliseconds) and longer (20 seconds) ToolTipManager sharedInstance = ToolTipManager.sharedInstance(); sharedInstance.setReshowDelay(10); sharedInstance.setInitialDelay(10); sharedInstance.setDismissDelay(60 * 1000); |
void | setTooltipDismissDelay() set Tooltip Dismiss Delay ToolTipManager.sharedInstance().setDismissDelay(TOOLTIP_DISMISS_DELAY); |
void | showTooltipNow(JComponent c) show Tooltip Now Action toolTipAction = c.getActionMap().get("postTip"); if (toolTipAction != null) { ActionEvent postTip = new ActionEvent(c, ActionEvent.ACTION_PERFORMED, ""); toolTipAction.actionPerformed(postTip); |
void | showToolTipNow(JComponent component) show Tool Tip Now ToolTipManager manager = ToolTipManager.sharedInstance(); int oldDelay = manager.getInitialDelay(); manager.setInitialDelay(0); manager.mouseMoved( new MouseEvent(component, MouseEvent.MOUSE_MOVED, System.currentTimeMillis(), 0, 0, 0, 0, false)); manager.setInitialDelay(oldDelay); |