本文整理匯總了Java中javax.swing.JToolTip.getTipText方法的典型用法代碼示例。如果您正苦於以下問題:Java JToolTip.getTipText方法的具體用法?Java JToolTip.getTipText怎麽用?Java JToolTip.getTipText使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.swing.JToolTip
的用法示例。
在下文中一共展示了JToolTip.getTipText方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getPreferredSize
import javax.swing.JToolTip; //導入方法依賴的package包/類
/**
* This method returns the preferred size of the given JComponent.
*
* @param c The JComponent to find a preferred size for.
*
* @return The preferred size.
*/
public Dimension getPreferredSize(JComponent c)
{
JToolTip tip = (JToolTip) c;
String str = tip.getTipText();
FontMetrics fm = c.getFontMetrics(c.getFont());
Insets i = c.getInsets();
Dimension d = new Dimension(i.left + i.right, i.top + i.bottom);
if (str != null && ! str.equals(""))
{
View view = (View) c.getClientProperty(BasicHTML.propertyKey);
if (view != null)
{
d.width += (int) view.getPreferredSpan(View.X_AXIS);
d.height += (int) view.getPreferredSpan(View.Y_AXIS);
}
else
{
d.width += fm.stringWidth(str) + 6;
d.height += fm.getHeight();
}
}
return d;
}
示例2: propertyChange
import javax.swing.JToolTip; //導入方法依賴的package包/類
/**
* @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);
}
}
示例3: propertyChange
import javax.swing.JToolTip; //導入方法依賴的package包/類
public void propertyChange(PropertyChangeEvent e)
{
String prop = e.getPropertyName();
if (prop.equals("tiptext") || prop.equals("font")
|| prop.equals("foreground"))
{
JToolTip tip = (JToolTip) e.getSource();
String text = tip.getTipText();
BasicHTML.updateRenderer(tip, text);
}
}
示例4: paint
import javax.swing.JToolTip; //導入方法依賴的package包/類
/**
* This method paints the given JComponent with the given Graphics object.
*
* @param g The Graphics object to paint with.
* @param c The JComponent to paint.
*/
public void paint(Graphics g, JComponent c)
{
JToolTip tip = (JToolTip) c;
String text = tip.getTipText();
Font font = c.getFont();
FontMetrics fm = c.getFontMetrics(font);
int ascent = fm.getAscent();
Insets i = c.getInsets();
Dimension size = c.getSize();
Rectangle paintR = new Rectangle(i.left, i.top,
size.width - i.left - i.right,
size.height - i.top - i.bottom);
Color saved = g.getColor();
Font oldFont = g.getFont();
g.setColor(Color.BLACK);
View view = (View) c.getClientProperty(BasicHTML.propertyKey);
if (view != null)
view.paint(g, paintR);
else
g.drawString(text, paintR.x + 3, paintR.y + ascent);
g.setFont(oldFont);
g.setColor(saved);
}
示例5: paint
import javax.swing.JToolTip; //導入方法依賴的package包/類
/**
* This method paints the given JComponent with the given Graphics object.
*
* @param g The Graphics object to paint with.
* @param c The JComponent to paint.
*/
public void paint(Graphics g, JComponent c)
{
JToolTip tip = (JToolTip) c;
String text = tip.getTipText();
Font font = c.getFont();
FontMetrics fm = c.getFontMetrics(font);
int ascent = fm.getAscent();
Insets i = c.getInsets();
Dimension size = c.getSize();
Rectangle paintR = new Rectangle(i.left, i.top,
size.width - i.left - i.right,
size.height - i.top - i.bottom);
Color saved = g.getColor();
Font oldFont = g.getFont();
g.setColor(Color.BLACK);
View view = (View) c.getClientProperty(BasicHTML.propertyKey);
if (view != null)
view.paint(g, paintR);
else
g.drawString(text, paintR.x + 3, paintR.y + ascent);
g.setFont(oldFont);
g.setColor(saved);
}