类javax.swing.plaf.basic.BasicHTML源码实例Demo

下面列出了怎么用javax.swing.plaf.basic.BasicHTML的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: jdk8u-jdk   文件: SynthToolTipUI.java
/**
 * {@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);
    }
}
 
源代码2 项目: darklaf   文件: TabbedPaneHandler.java
protected void updateHtmlViews(final int index, final boolean inserted) {
    String title = ui.tabPane.getTitleAt(index);
    boolean isHTML = BasicHTML.isHTMLString(title);
    if (isHTML) {
        if (ui.htmlViews == null) { // Initialize vector
            ui.htmlViews = ui.createHTMLVector();
        } else { // Vector already exists
            View v = BasicHTML.createHTMLView(ui.tabPane, title);
            setHtmlView(v, inserted, index);
        }
    } else { // Not HTML
        if (ui.htmlViews != null) { // Add placeholder
            setHtmlView(null, inserted, index);
        } // else nada!
    }
    ui.updateMnemonics();
}
 
源代码3 项目: jdk1.8-source-analysis   文件: TitledBorder.java
/**
 * 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);
}
 
源代码4 项目: consulo   文件: DesktopAlertImpl.java
@Nonnull
public JTextPane configureMessagePaneUi(@Nonnull JTextPane messageComponent, @Nullable String message, @Nullable UIUtil.FontSize fontSize) {
  UIUtil.FontSize fixedFontSize = fontSize == null ? UIUtil.FontSize.NORMAL : fontSize;
  messageComponent.setFont(UIUtil.getLabelFont(fixedFontSize));
  if (BasicHTML.isHTMLString(message)) {
    HTMLEditorKit editorKit = new HTMLEditorKit();
    Font font = UIUtil.getLabelFont(fixedFontSize);
    editorKit.getStyleSheet().addRule(UIUtil.displayPropertiesToCSS(font, UIUtil.getLabelForeground()));
    messageComponent.setEditorKit(editorKit);
    messageComponent.setContentType(UIUtil.HTML_MIME);
  }
  messageComponent.setText(message);
  messageComponent.setEditable(false);
  if (messageComponent.getCaret() != null) {
    messageComponent.setCaretPosition(0);
  }

  messageComponent.setBackground(UIUtil.getOptionPaneBackground());
  messageComponent.setForeground(UIUtil.getLabelForeground());
  return messageComponent;
}
 
源代码5 项目: openjdk-jdk8u-backup   文件: SynthToolTipUI.java
/**
 * 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);
    }
}
 
/**
 * 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;
}
 
源代码7 项目: openjdk-8-source   文件: SynthToolTipUI.java
/**
 * {@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);
    }
}
 
源代码8 项目: openjdk-jdk9   文件: SynthToolTipUI.java
/**
 * {@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);
    }
}
 
源代码9 项目: jdk1.8-source-analysis   文件: SynthToolTipUI.java
/**
 * 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);
    }
}
 
源代码10 项目: jdk1.8-source-analysis   文件: SynthToolTipUI.java
/**
 * {@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);
    }
}
 
源代码11 项目: pgptool   文件: JXLabel.java
@Override
public void reshape(int x, int y, int w, int h) {
	int oldH = getHeight();
	super.reshape(x, y, w, h);
	if (!isLineWrap()) {
		return;
	}
	if (oldH == 0) {
		return;
	}
	if (w > getVisibleRect().width) {
		w = getVisibleRect().width;
	}
	View view = (View) getClientProperty(BasicHTML.propertyKey);
	if (view != null && view instanceof Renderer) {
		view.setSize(w - occupiedWidth, h);
	}

}
 
源代码12 项目: dragonwell8_jdk   文件: TitledBorder.java
/**
 * 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);
}
 
源代码13 项目: jdk8u_jdk   文件: SynthGraphicsUtils.java
/**
 * 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;
}
 
源代码14 项目: consulo   文件: HelpTooltip.java
void setSizeForWidth(float width) {
  if (width > MAX_WIDTH.get()) {
    View v = (View)getClientProperty(BasicHTML.propertyKey);
    if (v != null) {
      width = 0.0f;
      for (View row : getRows(v)) {
        float rWidth = row.getPreferredSpan(View.X_AXIS);
        if (width < rWidth) {
          width = rWidth;
        }
      }

      v.setSize(width, v.getPreferredSpan(View.Y_AXIS));
    }
  }
}
 
源代码15 项目: openjdk-jdk8u-backup   文件: SynthToolTipUI.java
/**
 * {@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);
    }
}
 
源代码16 项目: Java8CN   文件: TitledBorder.java
/**
 * 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);
}
 
源代码17 项目: openjdk-8-source   文件: TitledBorder.java
/**
 * 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);
}
 
源代码18 项目: TencentKona-8   文件: SynthGraphicsUtils.java
/**
 * 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;
}
 
源代码19 项目: TencentKona-8   文件: SynthGraphicsUtils.java
/**
 * 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;
}
 
源代码20 项目: openjdk-jdk8u-backup   文件: SynthGraphicsUtils.java
/**
 * 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;
}
 
源代码21 项目: TencentKona-8   文件: SynthToolTipUI.java
/**
 * {@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);
    }
}
 
源代码22 项目: jdk8u60   文件: SynthGraphicsUtils.java
/**
 * 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;
}
 
源代码23 项目: java-swing-tips   文件: MainPanel.java
public static int getFirstLineCenterY(String text, AbstractButton c, Rectangle iconRect) {
  int y = 0;
  if (Objects.nonNull(text) && c.getVerticalTextPosition() == SwingConstants.TOP) {
    View v = (View) c.getClientProperty(BasicHTML.propertyKey);
    if (Objects.nonNull(v)) {
      try {
        Element e = v.getElement().getElement(0);
        Shape s = new Rectangle();
        Position.Bias b = Position.Bias.Forward;
        s = v.modelToView(e.getStartOffset(), b, e.getEndOffset(), b, s);
        // System.out.println("v.h: " + s.getBounds());
        y = Math.round(Math.abs(s.getBounds().height - iconRect.height) / 2f);
      } catch (BadLocationException ex) {
        // should never happen
        RuntimeException wrap = new StringIndexOutOfBoundsException(ex.offsetRequested());
        wrap.initCause(ex);
        throw wrap;
      }
    }
  }
  return y;
}
 
源代码24 项目: jdk8u60   文件: SynthToolTipUI.java
/**
 * 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);
    }
}
 
源代码25 项目: jdk8u60   文件: SynthToolTipUI.java
/**
 * {@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);
    }
}
 
源代码26 项目: jdk8u-jdk   文件: TitledBorder.java
/**
 * 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);
}
 
源代码27 项目: JDKSourceCode1.8   文件: TitledBorder.java
/**
 * 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);
}
 
源代码28 项目: jdk8u-jdk   文件: SynthToolTipUI.java
/**
 * {@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);
    }
}
 
源代码29 项目: JDKSourceCode1.8   文件: SynthGraphicsUtils.java
/**
 * 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;
}
 
源代码30 项目: openjdk-jdk9   文件: TitledBorder.java
/**
 * 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();
}
 
 类所在包
 同包方法