/** * Gets the text displayed as a tooltip. * * @return Displayed text. */ public String getText() { return toolTip.getTipText(); }
public String getText() { return toolTip.getTipText(); }
public Dimension getPreferredSize(JComponent c) { String tipText = ((JToolTip) c).getTipText(); if (tipText == null) { return new Dimension(0, 0); } textArea.setText(tipText); Dimension d = textArea.getPreferredSize(); d.width = Math.min(d.width, WIDTH); d.height++; textArea.setSize(d); return d; //return textArea.getPreferredSize(); } }
/** * @see JWindow#setVisible(boolean) */ @Override public void setVisible(boolean visible) { setSize(toolTip.getPreferredSize()); followOwner(); if ((toolTip.getTipText() != null) && (!toolTip.getTipText().isEmpty())) { super.setVisible(visible); } }
@Override public void setVisible(final boolean visible) { setSize(toolTip.getPreferredSize()); followOwner(); if ((toolTip.getTipText() != null) && (!toolTip.getTipText().isEmpty())) { super.setVisible(visible); } }
public void paint(Graphics g, JComponent c) { JToolTip toolTip = (JToolTip) c; String tipText = toolTip.getTipText(); if (tipText == null) return; Graphics2D g2 = (Graphics2D) g; JComponent subject = toolTip.getComponent(); g2.setPaint(subject.getBackground()); g2.fill(g2.getClip()); g2.setPaint(subject.getForeground()); g2.drawString(tipText, 1, g2.getFontMetrics().getAscent()); }
/** * @inheritDoc */ @Override public void propertyChange(PropertyChangeEvent e) { if (SeaGlassLookAndFeel.shouldUpdateStyle(e)) { updateStyle((JToolTip) e.getSource()); } String name = e.getPropertyName(); if (name.equals("tiptext") || "font".equals(name) || "foreground".equals(name)) { // remove the old html view client property if one // existed, and install a new one if the text installed // into the JLabel is html source. JToolTip tip = ((JToolTip) e.getSource()); String text = tip.getTipText(); BasicHTML.updateRenderer(tip, text); } } }
public void paint(Graphics g, JComponent c) { super.paint(g, c); Font font = c.getFont(); FontMetrics metrics = Toolkit.getDefaultToolkit().getFontMetrics(font); String keyText = getAcceleratorString(); String tipText = ((JToolTip)c).getTipText(); if (tipText == null) { tipText = ""; } if (! (keyText.equals(""))) { // only draw control key if there is one g.setFont(smallFont); g.setColor( c.getForeground() ); // from http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4449310 metrics = c.getFontMetrics(smallFont); g.drawString(keyText, c.getWidth() - 2 - metrics.stringWidth(keyText), c.getHeight() - 2 - metrics.getDescent()); } }
String tipText = ((JToolTip)comp).getTipText(); if ( tipText == null ) { tipText = "";
@Override public Dimension getPreferredSize(JComponent c) { Font font = c.getFont(); Insets insets = c.getInsets(); Dimension prefSize = new Dimension(insets.left + insets.right, insets.top + insets.bottom); String text = ((JToolTip) c).getTipText(); if ((text == null) || text.equals("")) { text = ""; } else { View v = (c != null) ? (View) c.getClientProperty("html") : null; if (v != null) { // fix for 302 - add extra pixels for the HTML view as well prefSize.width += (int) (v.getPreferredSpan(View.X_AXIS) + 6); prefSize.height += (int) (v.getPreferredSpan(View.Y_AXIS) + 2); } else { FontMetrics fm = c.getFontMetrics(font); prefSize.width += fm.stringWidth(text) + 6; prefSize.height += fm.getHeight() + 2; } } return prefSize; }
String tipText = ((JToolTip)c).getTipText(); if (tipText != null) { g.setColor(c.getForeground());
@Override public Dimension getPreferredSize(JComponent c) { Font font = c.getFont(); Insets insets = c.getInsets(); Dimension prefSize = new Dimension(insets.left + insets.right, insets.top + insets.bottom); String text = ((JToolTip) c).getTipText(); if ((text == null) || text.equals("")) { text = ""; } else { View v = (c != null) ? (View) c.getClientProperty("html") : null; if (v != null) { // fix for 302 - add extra pixels for the HTML view as well prefSize.width += (int) (v.getPreferredSpan(View.X_AXIS) + 6); prefSize.height += (int) (v.getPreferredSpan(View.Y_AXIS) + 2); } else { FontMetrics fm = c.getFontMetrics(font); prefSize.width += fm.stringWidth(text) + 6; prefSize.height += fm.getHeight() + 2; } } return prefSize; }
String tipText = ((JToolTip) c).getTipText(); if (tipText == null) { return new Dimension(0, 0);
FontMetrics metrics = c.getFontMetrics(font); String keyText = getAcceleratorString(); String tipText = tip.getTipText(); if (tipText == null) { tipText = "";
public void setText(final String text) { // Only change if different if (!ValueUtils.areEqual(text, toolTip.getTipText())) { final boolean wasVisible = isVisible(); if (wasVisible) { setVisible(false); } toolTip.setTipText(text); if (wasVisible) { setVisible(wasVisible); } } }
@Override public void paint(Graphics g, JComponent c) { Font font = c.getFont(); // FontMetrics metrics = c.getFontMetrics(font); Dimension size = c.getSize(); if (c.isOpaque()) { g.setColor(c.getBackground()); g.fillRect(0, 0, size.width, size.height); } g.setColor(c.getForeground()); g.setFont(font); // fix for bug 4153892 String tipText = ((JToolTip) c).getTipText(); if (tipText == null) { tipText = ""; } Insets insets = c.getInsets(); Rectangle paintTextR = new Rectangle(insets.left + 3, insets.top, size.width - (insets.left + insets.right + 6), size.height - (insets.top + insets.bottom + 2)); View v = (View) c.getClientProperty(BasicHTML.propertyKey); if (v != null) { v.paint(g, paintTextR); } else { SubstanceTextUtilities.paintText(g, c, paintTextR, tipText, -1, font, c.getForeground(), null); } }
@Override public void paint(Graphics g, JComponent c) { Font font = c.getFont(); // FontMetrics metrics = c.getFontMetrics(font); Dimension size = c.getSize(); if (c.isOpaque()) { g.setColor(c.getBackground()); g.fillRect(0, 0, size.width, size.height); } g.setColor(c.getForeground()); g.setFont(font); // fix for bug 4153892 String tipText = ((JToolTip) c).getTipText(); if (tipText == null) { tipText = ""; } Insets insets = c.getInsets(); Rectangle paintTextR = new Rectangle(insets.left + 3, insets.top, size.width - (insets.left + insets.right + 6), size.height - (insets.top + insets.bottom + 2)); View v = (View) c.getClientProperty(BasicHTML.propertyKey); if (v != null) { v.paint(g, paintTextR); } else { SubstanceTextUtilities.paintText(g, c, paintTextR, tipText, -1, font, c.getForeground(), null); } }
/** * Sets the text to be displayed as a tooltip. * * @param text Text to be displayed */ public void setText(String text) { // Only change if different if (!ValueUtils.areEqual(text, toolTip.getTipText())) { boolean wasVisible = isVisible(); if (wasVisible) { setVisible(false); } toolTip.setTipText(text); if (wasVisible) { setVisible(true); } } }
/** * Paints the specified component. * * @param context * context for the component being painted * @param g * the {@code Graphics} object used for painting * @see #update(Graphics,JComponent) */ protected void paint(SynthContext context, Graphics g) { JToolTip tip = (JToolTip) context.getComponent(); Insets insets = tip.getInsets(); View v = (View) tip.getClientProperty(BasicHTML.propertyKey); if (v != null) { Rectangle paintTextR = new Rectangle(insets.left, insets.top, tip.getWidth() - (insets.left + insets.right), tip.getHeight() - (insets.top + insets.bottom)); v.paint(g, paintTextR); } else { g.setColor(context.getStyle().getColor(context, ColorType.TEXT_FOREGROUND)); g.setFont(style.getFont(context)); context.getStyle().getGraphicsUtils(context).paintText(context, g, tip.getTipText(), insets.left, insets.top, -1); } }
/** * @inheritDoc */ @Override public Dimension getPreferredSize(JComponent c) { SeaGlassContext context = getContext(c); Insets insets = c.getInsets(); Dimension prefSize = new Dimension(insets.left + insets.right, insets.top + insets.bottom); String text = ((JToolTip) c).getTipText(); if (text != null) { View v = (c != null) ? (View) c.getClientProperty("html") : null; if (v != null) { prefSize.width += (int) v.getPreferredSpan(View.X_AXIS); prefSize.height += (int) v.getPreferredSpan(View.Y_AXIS); } else { Font font = context.getStyle().getFont(context); FontMetrics fm = c.getFontMetrics(font); prefSize.width += context.getStyle().getGraphicsUtils(context).computeStringWidth(context, font, fm, text); prefSize.height += fm.getHeight(); } } context.dispose(); return prefSize; }