/** * Overridden to use the editor's background if it's detected that the * user isn't using white as the editor bg, but the system's tool tip * background is yellow-ish. * * @return The tool tip. */ @Override public JToolTip createToolTip() { JToolTip tip = super.createToolTip(); Color textAreaBG = textArea.getBackground(); if (textAreaBG!=null && !Color.white.equals(textAreaBG)) { Color bg = TipUtil.getToolTipBackground(); // If current L&F's tool tip color is close enough to "yellow", // and we're not using the default text background of white, use // the editor background as the tool tip background. if (bg.getRed()>=240 && bg.getGreen()>=240 && bg.getBlue()>=200) { tip.setBackground(textAreaBG); } } return tip; }
@Override public JToolTip createToolTip() { JToolTip tooltip = super.createToolTip(); tooltip.setBorder(BorderFactory.createLineBorder(new Color(76,79,83))); tooltip.setBackground(new Color(255, 247, 200)); return tooltip; }
public JToolTip createToolTip() { JToolTip tip = super.createToolTip(); tip.setBackground(Color.yellow); return tip; }
public class Main { public static void main(String args[]) { JFrame frame = new JFrame("JToolTip Sample"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JButton b1 = new JButton("Button 1") { public JToolTip createToolTip() { JToolTip tip = super.createToolTip(); tip.setForeground(Color.YELLOW); tip.setBackground(Color.RED); tip.setFont(new Font("Arial", Font.BOLD,36)); return tip; } }; b1.setToolTipText("HELLO"); frame.add(b1, BorderLayout.NORTH); frame.setSize(300, 150); frame.setVisible(true); } }
@Override public JToolTip createToolTip() { JToolTip tooltip = super.createToolTip(); tooltip.setBackground(new Color(255, 255, 140, 128)); this.repaint(); // TODO: will this bog us down? return tooltip; }
public class CButton extends JButton { public CButton(String text, Icon icon) { super(text, icon); } @Override public JToolTip createToolTip() { JToolTip toolTip = super.createToolTip(); toolTip.setForeground(Color.BLACK); toolTip.setBackground(Color.WHITE); toolTip.setFont(new Font("Arial", Font.PLAIN, 12)); return toolTip; } };
/** * Overridden to use the editor's background if it's detected that the * user isn't using white as the editor bg, but the system's tool tip * background is yellow-ish. * * @return The tool tip. */ @Override public JToolTip createToolTip() { JToolTip tip = super.createToolTip(); Color textAreaBG = textArea.getBackground(); if (textAreaBG!=null && !Color.white.equals(textAreaBG)) { Color bg = TipUtil.getToolTipBackground(); // If current L&F's tool tip color is close enough to "yellow", // and we're not using the default text background of white, use // the editor background as the tool tip background. if (bg.getRed()>=240 && bg.getGreen()>=240 && bg.getBlue()>=200) { tip.setBackground(textAreaBG); } } 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; }
/** Creates a new instance of JExtendedTree */ public JExtendedTree() { addMouseListener(componentListener); addMouseMotionListener(componentListener); setRowHeight(UIUtils.getDefaultRowHeight()); // celltips require to have row height initialized! // --- CellTip support ------------------ cellTip = createCellTip(); cellTip.setBackground(getBackground()); cellTip.setBorder(BorderFactory.createLineBorder(UIConstants.TABLE_VERTICAL_GRID_COLOR)); cellTip.setLayout(new BorderLayout()); CellTipManager.sharedInstance().registerComponent(this); }