當前位置: 首頁>>代碼示例>>Java>>正文


Java JToolTip.getTipText方法代碼示例

本文整理匯總了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;
}
 
開發者ID:vilie,項目名稱:javify,代碼行數:31,代碼來源:BasicToolTipUI.java

示例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);
    }
}
 
開發者ID:khuxtable,項目名稱:seaglass,代碼行數:19,代碼來源:SeaGlassToolTipUI.java

示例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);
    }
}
 
開發者ID:vilie,項目名稱:javify,代碼行數:12,代碼來源:BasicToolTipUI.java

示例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);
}
 
開發者ID:vilie,項目名稱:javify,代碼行數:33,代碼來源:BasicToolTipUI.java

示例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);   
}
 
開發者ID:nmldiegues,項目名稱:jvm-stm,代碼行數:33,代碼來源:BasicToolTipUI.java


注:本文中的javax.swing.JToolTip.getTipText方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。