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


Java BasicHTML類代碼示例

本文整理匯總了Java中javax.swing.plaf.basic.BasicHTML的典型用法代碼示例。如果您正苦於以下問題:Java BasicHTML類的具體用法?Java BasicHTML怎麽用?Java BasicHTML使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


BasicHTML類屬於javax.swing.plaf.basic包,在下文中一共展示了BasicHTML類的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: setDisplayName

import javax.swing.plaf.basic.BasicHTML; //導入依賴的package包/類
/** Sets localized display name of this <code>TopComponent</code>.
 * @param displayName localized display name which is set
 * @since 4.13 */
public void setDisplayName(String displayName) {
    String old = this.displayName;

    if ((displayName == old) || ((displayName != null) && displayName.equals(old))) {
        return;
    }

    // warning if display name contains html tags
    if (BasicHTML.isHTMLString(displayName)) {
        Logger.getAnonymousLogger().warning(
            "Call of " + getClass().getName() + ".setDisplayName(\"" + displayName + "\")" +
            " shouldn't contain any HTML tags. Please use " + getClass().getName() + ".setHtmlDisplayName(String)" +
            "for such purpose. For details please see http://www.netbeans.org/issues/show_bug.cgi?id=66777.");
    }
    
    this.displayName = displayName;
    firePropertyChange("displayName", old, displayName); // NOI18N

    WindowManager.getDefault().topComponentDisplayNameChanged(this, displayName);
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:24,代碼來源:TopComponent.java

示例2: TitledBorder

import javax.swing.plaf.basic.BasicHTML; //導入依賴的package包/類
/**
 * Creates a TitledBorder instance with the specified border,
 * title, title-justification, title-position, title-font, and
 * title-color.
 *
 * @param border  the border
 * @param title  the title the border should display
 * @param titleJustification the justification for the title
 * @param titlePosition the position for the title
 * @param titleFont the font of the title
 * @param titleColor the color of the title
 */
@ConstructorProperties({"border", "title", "titleJustification", "titlePosition", "titleFont", "titleColor"})
public TitledBorder(Border border,
                    String title,
                    int titleJustification,
                    int titlePosition,
                    Font titleFont,
                    Color titleColor) {
    this.title = title;
    this.border = border;
    this.titleFont = titleFont;
    this.titleColor = titleColor;

    setTitleJustification(titleJustification);
    setTitlePosition(titlePosition);

    this.label = new JLabel();
    this.label.setOpaque(false);
    this.label.putClientProperty(BasicHTML.propertyKey, null);
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:32,代碼來源:TitledBorder.java

示例3: getMinimumSize

import javax.swing.plaf.basic.BasicHTML; //導入依賴的package包/類
/**
 * Returns the minimum size needed to properly render an icon and text.
 *
 * @param ss SynthContext
 * @param font Font to use
 * @param text Text to layout
 * @param icon Icon to layout
 * @param hAlign horizontal alignment
 * @param vAlign vertical alignment
 * @param hTextPosition horizontal text position
 * @param vTextPosition vertical text position
 * @param iconTextGap gap between icon and text
 * @param mnemonicIndex Index into text to render the mnemonic at, -1
 *        indicates no mnemonic.
 */
public Dimension getMinimumSize(SynthContext ss, Font font, String text,
                  Icon icon, int hAlign, int vAlign, int hTextPosition,
                  int vTextPosition, int iconTextGap, int mnemonicIndex) {
    JComponent c = ss.getComponent();
    Dimension size = getPreferredSize(ss, font, text, icon, hAlign,
                                      vAlign, hTextPosition, vTextPosition,
                                      iconTextGap, mnemonicIndex);
    View v = (View) c.getClientProperty(BasicHTML.propertyKey);

    if (v != null) {
        size.width -= v.getPreferredSpan(View.X_AXIS) -
                      v.getMinimumSpan(View.X_AXIS);
    }
    return size;
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:31,代碼來源:SynthGraphicsUtils.java

示例4: getMaximumSize

import javax.swing.plaf.basic.BasicHTML; //導入依賴的package包/類
/**
 * Returns the maximum size needed to properly render an icon and text.
 *
 * @param ss SynthContext
 * @param font Font to use
 * @param text Text to layout
 * @param icon Icon to layout
 * @param hAlign horizontal alignment
 * @param vAlign vertical alignment
 * @param hTextPosition horizontal text position
 * @param vTextPosition vertical text position
 * @param iconTextGap gap between icon and text
 * @param mnemonicIndex Index into text to render the mnemonic at, -1
 *        indicates no mnemonic.
 */
public Dimension getMaximumSize(SynthContext ss, Font font, String text,
                  Icon icon, int hAlign, int vAlign, int hTextPosition,
                  int vTextPosition, int iconTextGap, int mnemonicIndex) {
    JComponent c = ss.getComponent();
    Dimension size = getPreferredSize(ss, font, text, icon, hAlign,
                                      vAlign, hTextPosition, vTextPosition,
                                      iconTextGap, mnemonicIndex);
    View v = (View) c.getClientProperty(BasicHTML.propertyKey);

    if (v != null) {
        size.width += v.getMaximumSpan(View.X_AXIS) -
                      v.getPreferredSpan(View.X_AXIS);
    }
    return size;
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:31,代碼來源:SynthGraphicsUtils.java

示例5: paint

import javax.swing.plaf.basic.BasicHTML; //導入依賴的package包/類
/**
 * 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);
    }
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:26,代碼來源:SynthToolTipUI.java

示例6: propertyChange

import javax.swing.plaf.basic.BasicHTML; //導入依賴的package包/類
/**
 * {@inheritDoc}
 */
@Override
public void propertyChange(PropertyChangeEvent e) {
    if (SynthLookAndFeel.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:SunburstApps,項目名稱:OpenJSharp,代碼行數:20,代碼來源:SynthToolTipUI.java

示例7: TitledBorder

import javax.swing.plaf.basic.BasicHTML; //導入依賴的package包/類
/**
 * Creates a TitledBorder instance with the specified border,
 * title, title-justification, title-position, title-font, and
 * title-color.
 *
 * @param border  the border
 * @param title  the title the border should display
 * @param titleJustification the justification for the title
 * @param titlePosition the position for the title
 * @param titleFont the font of the title
 * @param titleColor the color of the title
 */
@ConstructorProperties({"border", "title", "titleJustification", "titlePosition", "titleFont", "titleColor"})
public TitledBorder(Border border,
                    String title,
                    int titleJustification,
                    int titlePosition,
                    Font titleFont,
                    Color titleColor) {
    this.title = title;
    this.border = border;
    this.titleFont = titleFont;
    this.titleColor = titleColor;

    setTitleJustification(titleJustification);
    setTitlePosition(titlePosition);

    this.label = new JLabel();
    this.label.setOpaque(false);
    this.label.putClientProperty(BasicHTML.propertyKey, null);
    installPropertyChangeListeners();
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:33,代碼來源:TitledBorder.java

示例8: componentAdded

import javax.swing.plaf.basic.BasicHTML; //導入依賴的package包/類
@Override
public void componentAdded(ContainerEvent e) {
	JTabbedPane tp = (JTabbedPane) e.getContainer();
	Component child = e.getChild();
	if (child instanceof UIResource) {
		return;
	}
	int index = tp.indexOfComponent(child);
	String title = tp.getTitleAt(index);
	boolean isHTML = BasicHTML.isHTMLString(title);
	if (isHTML) {
		if (htmlViews == null) { // Initialize vector
			htmlViews = createHTMLVector();
		}
		else { // Vector already exists
			View v = BasicHTML.createHTMLView(tp, title);
			htmlViews.insertElementAt(v, index);
		}
	}
	else { // Not HTML
		if (htmlViews != null) { // Add placeholder
			htmlViews.insertElementAt(null, index);
		} // else nada!
	}
}
 
開發者ID:MyersResearchGroup,項目名稱:iBioSim,代碼行數:26,代碼來源:CloseTabPaneUI.java

示例9: createHTMLVector

import javax.swing.plaf.basic.BasicHTML; //導入依賴的package包/類
private Vector<View> createHTMLVector() {
	Vector<View> htmlViews = new Vector<View>();
	int count = tabPane.getTabCount();
	if (count > 0) {
		for (int i = 0; i < count; i++) {
			String title = tabPane.getTitleAt(i);
			if (BasicHTML.isHTMLString(title)) {
				htmlViews.addElement(BasicHTML.createHTMLView(tabPane, title));
			}
			else {
				htmlViews.addElement(null);
			}
		}
	}
	return htmlViews;
}
 
開發者ID:MyersResearchGroup,項目名稱:iBioSim,代碼行數:17,代碼來源:CloseTabPaneUI.java

示例10: getCharacterBounds

import javax.swing.plaf.basic.BasicHTML; //導入依賴的package包/類
/**
 * Returns the bounding box of the character at the specified index.
 *
 * @param index the index of the character that we return the
 *        bounds for
 *
 * @return the bounding box of the character at the specified index
 */
public Rectangle getCharacterBounds(int index)
{
  Rectangle bounds = null;
  View view = (View) getClientProperty(BasicHTML.propertyKey);
  if (view != null)
    {
      Rectangle textR = getTextRectangle();
      try
        {
          Shape s = view.modelToView(index, textR, Position.Bias.Forward);
          bounds = s.getBounds();
        }
      catch (BadLocationException ex)
        {
          // Can't return something reasonable in this case.
        }
    }
  return bounds;
}
 
開發者ID:vilie,項目名稱:javify,代碼行數:28,代碼來源:JLabel.java

示例11: getCharacterBounds

import javax.swing.plaf.basic.BasicHTML; //導入依賴的package包/類
/**
 * Returns the bounds of the character at the specified index of the
 * button's label. This will only work for HTML labels.
 *
 * @param i the index of the character of the label
 *
 * @return the bounds of the character at the specified index of the
 *         button's label
 */
public Rectangle getCharacterBounds(int i)
{
  Rectangle rect = null;
  View view = (View) getClientProperty(BasicHTML.propertyKey);
  if (view != null)
    {
      Rectangle shape = new Rectangle(0, 0, getWidth(), getHeight());
      try
        {
          Shape s = view.modelToView(i, shape, Position.Bias.Forward);
          rect = s.getBounds();
        }
      catch (BadLocationException ex)
        {
          rect = null;
        }
    }
  return rect;
}
 
開發者ID:vilie,項目名稱:javify,代碼行數:29,代碼來源:AbstractButton.java

示例12: getCharacterAttribute

import javax.swing.plaf.basic.BasicHTML; //導入依賴的package包/類
/**
 * Returns the text attribute for the character at the specified character
 * index.
 *
 * @param i the character index
 *
 * @return the character attributes for the specified character or
 *         <code>null</code> if the character has no attributes
 */
public AttributeSet getCharacterAttribute(int i)
{
  AttributeSet atts = null;
  View view = (View) getClientProperty(BasicHTML.propertyKey);
  if (view != null)
    {
      Document doc = view.getDocument();
      if (doc instanceof StyledDocument)
        {
          StyledDocument sDoc = (StyledDocument) doc;
          Element charEl = sDoc.getCharacterElement(i);
          if (charEl != null)
            atts = charEl.getAttributes();
        }
    }
  return atts;
}
 
開發者ID:vilie,項目名稱:javify,代碼行數:27,代碼來源:AbstractButton.java

示例13: drawText

import javax.swing.plaf.basic.BasicHTML; //導入依賴的package包/類
protected void drawText(AbstractButton b, Graphics2D g, String text, Rectangle textRect, FontMetrics fm) {
  // Draw the Text
  if(text != null) {
    View v = (View) b.getClientProperty(BasicHTML.propertyKey);
    if (v != null) {
      v.paint(g, textRect);
    } else {
      int mnemIndex = b.getDisplayedMnemonicIndex();
      if(b.isEnabled()) {
        // *** paint the text normally
        g.setColor(b.getForeground());
      } else {
        // *** paint the text disabled
        g.setColor(getDisabledTextColor());
      }
      SwingUtilities2.drawStringUnderlineCharAt(b, g, text,
                                                mnemIndex, textRect.x, textRect.y + fm.getAscent());
    }
  }
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:21,代碼來源:DarculaRadioButtonUI.java


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