@Override public JToolTip createToolTip() { JLabel label = new JLabel("", new ImageIcon(url), SwingConstants.LEFT); JToolTip tip = new AnimatedToolTip(label); tip.setComponent(this); return tip; } };
JButton btn = new JButton("SAVE"){ public JToolTip createToolTip() { JToolTip tip_for_button = new JToolTip(){ public String getTipText() { return "blah blah"; } }; tip_for_button.setComponent(this); return tip_for_button; } }; btn.setToolTipText("notnull");
private JToolTip prepareTooltip(JComponent content) { JToolTip toolTip = new JToolTip(); toolTip.setLayout(new BorderLayout()); toolTip.add(content); toolTip.setPreferredSize(content.getPreferredSize()); toolTip.setFocusable(false); toolTip.setComponent(this); ToolTipManager.sharedInstance().setDismissDelay(TOOL_TIP_DISMISS_DELAY); return toolTip; }
@Override public JToolTip createToolTip() { JToolTip tip = new AnimatedToolTip(new AnimatedLabel("")); tip.setComponent(this); return tip; } };
/** * Creates a new tooltip. If overlapping is true then the tooltip will take on the foreground/background color and * font of the specified component (if the component isspecifiedd) * * @param c the component the tooltip describes * @param overlapping whether the tooltip is for a normal or overlapping tooltip * @return the new tooltip object */ public JToolTip createToolTip(JComponent c, boolean overlapping) { JToolTip tt = new JToolTip(); if (c != null) { tt.setComponent(c); if (overlapping) { if (c.getBackground() != null) { Color bg = c.getBackground(); if (bg.getAlpha() != 255) { bg = new Color(bg.getRed(), bg.getGreen(), bg.getBlue()); } tt.setBackground(bg); } if (c.getForeground() != null) { tt.setForeground(c.getForeground()); } if (c.getFont() != null) { tt.setFont(c.getFont()); } } } return tt; }
setComponent(component); setBackground(Color.black); setForeground(Color.red);