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

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

源代码1 项目: consulo   文件: CheckBoxList.java
@Nonnull
private static Dimension getCheckBoxDimension(@Nonnull JCheckBox checkBox) {
  Icon icon = null;
  BasicRadioButtonUI ui = ObjectUtils.tryCast(checkBox.getUI(), BasicRadioButtonUI.class);
  if (ui != null) {
    icon = ui.getDefaultIcon();
  }
  if (icon == null) {
    // com.intellij.ide.ui.laf.darcula.ui.DarculaCheckBoxUI.getDefaultIcon()
    icon = JBUI.scale(EmptyIcon.create(20));
  }
  Insets margin = checkBox.getMargin();
  return new Dimension(margin.left + icon.getIconWidth(), margin.top + icon.getIconHeight());
}
 
源代码2 项目: consulo   文件: JBCheckBox.java
/**
 * Sets given icon to display between checkbox icon and text.
 *
 * @return true in case of success and false otherwise
 */
public boolean setTextIcon(@Nonnull Icon icon) {
  ButtonUI ui = getUI();
  if (ui instanceof BasicRadioButtonUI) {
    Icon defaultIcon = ((BasicRadioButtonUI) ui).getDefaultIcon();
    if (defaultIcon != null) {
      MergedIcon mergedIcon = new MergedIcon(defaultIcon, 10, icon);
      setIcon(mergedIcon);
      return true;
    }
  }
  return false;
}
 
源代码3 项目: dragonwell8_jdk   文件: ConnectDialog.java
private static Rectangle getTextRectangle(AbstractButton button) {
    String text = button.getText();
    Icon icon = (button.isEnabled()) ? button.getIcon() : button.getDisabledIcon();

    if (icon == null && button.getUI() instanceof BasicRadioButtonUI) {
        icon = ((BasicRadioButtonUI)button.getUI()).getDefaultIcon();
    }

    if ((icon == null) && (text == null)) {
        return null;
    }

    Rectangle paintIconR = new Rectangle();
    Rectangle paintTextR = new Rectangle();
    Rectangle paintViewR = new Rectangle();
    Insets paintViewInsets = new Insets(0, 0, 0, 0);

    paintViewInsets = button.getInsets(paintViewInsets);
    paintViewR.x = paintViewInsets.left;
    paintViewR.y = paintViewInsets.top;
    paintViewR.width = button.getWidth() - (paintViewInsets.left + paintViewInsets.right);
    paintViewR.height = button.getHeight() - (paintViewInsets.top + paintViewInsets.bottom);

    Graphics g = button.getGraphics();
    if (g == null) {
        return null;
    }
        SwingUtilities.layoutCompoundLabel(button,
                                           g.getFontMetrics(),
                                           text,
                                           icon,
                                           button.getVerticalAlignment(),
                                           button.getHorizontalAlignment(),
                                           button.getVerticalTextPosition(),
                                           button.getHorizontalTextPosition(),
                                           paintViewR,
                                           paintIconR,
                                           paintTextR,
                                           button.getIconTextGap());

    return paintTextR;
}
 
源代码4 项目: TencentKona-8   文件: ConnectDialog.java
private static Rectangle getTextRectangle(AbstractButton button) {
    String text = button.getText();
    Icon icon = (button.isEnabled()) ? button.getIcon() : button.getDisabledIcon();

    if (icon == null && button.getUI() instanceof BasicRadioButtonUI) {
        icon = ((BasicRadioButtonUI)button.getUI()).getDefaultIcon();
    }

    if ((icon == null) && (text == null)) {
        return null;
    }

    Rectangle paintIconR = new Rectangle();
    Rectangle paintTextR = new Rectangle();
    Rectangle paintViewR = new Rectangle();
    Insets paintViewInsets = new Insets(0, 0, 0, 0);

    paintViewInsets = button.getInsets(paintViewInsets);
    paintViewR.x = paintViewInsets.left;
    paintViewR.y = paintViewInsets.top;
    paintViewR.width = button.getWidth() - (paintViewInsets.left + paintViewInsets.right);
    paintViewR.height = button.getHeight() - (paintViewInsets.top + paintViewInsets.bottom);

    Graphics g = button.getGraphics();
    if (g == null) {
        return null;
    }
        SwingUtilities.layoutCompoundLabel(button,
                                           g.getFontMetrics(),
                                           text,
                                           icon,
                                           button.getVerticalAlignment(),
                                           button.getHorizontalAlignment(),
                                           button.getVerticalTextPosition(),
                                           button.getHorizontalTextPosition(),
                                           paintViewR,
                                           paintIconR,
                                           paintTextR,
                                           button.getIconTextGap());

    return paintTextR;
}
 
源代码5 项目: jdk8u60   文件: ConnectDialog.java
private static Rectangle getTextRectangle(AbstractButton button) {
    String text = button.getText();
    Icon icon = (button.isEnabled()) ? button.getIcon() : button.getDisabledIcon();

    if (icon == null && button.getUI() instanceof BasicRadioButtonUI) {
        icon = ((BasicRadioButtonUI)button.getUI()).getDefaultIcon();
    }

    if ((icon == null) && (text == null)) {
        return null;
    }

    Rectangle paintIconR = new Rectangle();
    Rectangle paintTextR = new Rectangle();
    Rectangle paintViewR = new Rectangle();
    Insets paintViewInsets = new Insets(0, 0, 0, 0);

    paintViewInsets = button.getInsets(paintViewInsets);
    paintViewR.x = paintViewInsets.left;
    paintViewR.y = paintViewInsets.top;
    paintViewR.width = button.getWidth() - (paintViewInsets.left + paintViewInsets.right);
    paintViewR.height = button.getHeight() - (paintViewInsets.top + paintViewInsets.bottom);

    Graphics g = button.getGraphics();
    if (g == null) {
        return null;
    }
        SwingUtilities.layoutCompoundLabel(button,
                                           g.getFontMetrics(),
                                           text,
                                           icon,
                                           button.getVerticalAlignment(),
                                           button.getHorizontalAlignment(),
                                           button.getVerticalTextPosition(),
                                           button.getHorizontalTextPosition(),
                                           paintViewR,
                                           paintIconR,
                                           paintTextR,
                                           button.getIconTextGap());

    return paintTextR;
}
 
源代码6 项目: openjdk-jdk8u   文件: ConnectDialog.java
private static Rectangle getTextRectangle(AbstractButton button) {
    String text = button.getText();
    Icon icon = (button.isEnabled()) ? button.getIcon() : button.getDisabledIcon();

    if (icon == null && button.getUI() instanceof BasicRadioButtonUI) {
        icon = ((BasicRadioButtonUI)button.getUI()).getDefaultIcon();
    }

    if ((icon == null) && (text == null)) {
        return null;
    }

    Rectangle paintIconR = new Rectangle();
    Rectangle paintTextR = new Rectangle();
    Rectangle paintViewR = new Rectangle();
    Insets paintViewInsets = new Insets(0, 0, 0, 0);

    paintViewInsets = button.getInsets(paintViewInsets);
    paintViewR.x = paintViewInsets.left;
    paintViewR.y = paintViewInsets.top;
    paintViewR.width = button.getWidth() - (paintViewInsets.left + paintViewInsets.right);
    paintViewR.height = button.getHeight() - (paintViewInsets.top + paintViewInsets.bottom);

    Graphics g = button.getGraphics();
    if (g == null) {
        return null;
    }
        SwingUtilities.layoutCompoundLabel(button,
                                           g.getFontMetrics(),
                                           text,
                                           icon,
                                           button.getVerticalAlignment(),
                                           button.getHorizontalAlignment(),
                                           button.getVerticalTextPosition(),
                                           button.getHorizontalTextPosition(),
                                           paintViewR,
                                           paintIconR,
                                           paintTextR,
                                           button.getIconTextGap());

    return paintTextR;
}
 
源代码7 项目: openjdk-jdk8u-backup   文件: ConnectDialog.java
private static Rectangle getTextRectangle(AbstractButton button) {
    String text = button.getText();
    Icon icon = (button.isEnabled()) ? button.getIcon() : button.getDisabledIcon();

    if (icon == null && button.getUI() instanceof BasicRadioButtonUI) {
        icon = ((BasicRadioButtonUI)button.getUI()).getDefaultIcon();
    }

    if ((icon == null) && (text == null)) {
        return null;
    }

    Rectangle paintIconR = new Rectangle();
    Rectangle paintTextR = new Rectangle();
    Rectangle paintViewR = new Rectangle();
    Insets paintViewInsets = new Insets(0, 0, 0, 0);

    paintViewInsets = button.getInsets(paintViewInsets);
    paintViewR.x = paintViewInsets.left;
    paintViewR.y = paintViewInsets.top;
    paintViewR.width = button.getWidth() - (paintViewInsets.left + paintViewInsets.right);
    paintViewR.height = button.getHeight() - (paintViewInsets.top + paintViewInsets.bottom);

    Graphics g = button.getGraphics();
    if (g == null) {
        return null;
    }
        SwingUtilities.layoutCompoundLabel(button,
                                           g.getFontMetrics(),
                                           text,
                                           icon,
                                           button.getVerticalAlignment(),
                                           button.getHorizontalAlignment(),
                                           button.getVerticalTextPosition(),
                                           button.getHorizontalTextPosition(),
                                           paintViewR,
                                           paintIconR,
                                           paintTextR,
                                           button.getIconTextGap());

    return paintTextR;
}
 
源代码8 项目: openjdk-jdk9   文件: ConnectDialog.java
private static Rectangle getTextRectangle(AbstractButton button) {
    String text = button.getText();
    Icon icon = (button.isEnabled()) ? button.getIcon() : button.getDisabledIcon();

    if (icon == null && button.getUI() instanceof BasicRadioButtonUI) {
        icon = ((BasicRadioButtonUI)button.getUI()).getDefaultIcon();
    }

    if ((icon == null) && (text == null)) {
        return null;
    }

    Rectangle paintIconR = new Rectangle();
    Rectangle paintTextR = new Rectangle();
    Rectangle paintViewR = new Rectangle();
    Insets paintViewInsets = new Insets(0, 0, 0, 0);

    paintViewInsets = button.getInsets(paintViewInsets);
    paintViewR.x = paintViewInsets.left;
    paintViewR.y = paintViewInsets.top;
    paintViewR.width = button.getWidth() - (paintViewInsets.left + paintViewInsets.right);
    paintViewR.height = button.getHeight() - (paintViewInsets.top + paintViewInsets.bottom);

    Graphics g = button.getGraphics();
    if (g == null) {
        return null;
    }
        SwingUtilities.layoutCompoundLabel(button,
                                           g.getFontMetrics(),
                                           text,
                                           icon,
                                           button.getVerticalAlignment(),
                                           button.getHorizontalAlignment(),
                                           button.getVerticalTextPosition(),
                                           button.getHorizontalTextPosition(),
                                           paintViewR,
                                           paintIconR,
                                           paintTextR,
                                           button.getIconTextGap());

    return paintTextR;
}
 
源代码9 项目: jdk8u-jdk   文件: ConnectDialog.java
private static Rectangle getTextRectangle(AbstractButton button) {
    String text = button.getText();
    Icon icon = (button.isEnabled()) ? button.getIcon() : button.getDisabledIcon();

    if (icon == null && button.getUI() instanceof BasicRadioButtonUI) {
        icon = ((BasicRadioButtonUI)button.getUI()).getDefaultIcon();
    }

    if ((icon == null) && (text == null)) {
        return null;
    }

    Rectangle paintIconR = new Rectangle();
    Rectangle paintTextR = new Rectangle();
    Rectangle paintViewR = new Rectangle();
    Insets paintViewInsets = new Insets(0, 0, 0, 0);

    paintViewInsets = button.getInsets(paintViewInsets);
    paintViewR.x = paintViewInsets.left;
    paintViewR.y = paintViewInsets.top;
    paintViewR.width = button.getWidth() - (paintViewInsets.left + paintViewInsets.right);
    paintViewR.height = button.getHeight() - (paintViewInsets.top + paintViewInsets.bottom);

    Graphics g = button.getGraphics();
    if (g == null) {
        return null;
    }
        SwingUtilities.layoutCompoundLabel(button,
                                           g.getFontMetrics(),
                                           text,
                                           icon,
                                           button.getVerticalAlignment(),
                                           button.getHorizontalAlignment(),
                                           button.getVerticalTextPosition(),
                                           button.getHorizontalTextPosition(),
                                           paintViewR,
                                           paintIconR,
                                           paintTextR,
                                           button.getIconTextGap());

    return paintTextR;
}
 
源代码10 项目: hottub   文件: ConnectDialog.java
private static Rectangle getTextRectangle(AbstractButton button) {
    String text = button.getText();
    Icon icon = (button.isEnabled()) ? button.getIcon() : button.getDisabledIcon();

    if (icon == null && button.getUI() instanceof BasicRadioButtonUI) {
        icon = ((BasicRadioButtonUI)button.getUI()).getDefaultIcon();
    }

    if ((icon == null) && (text == null)) {
        return null;
    }

    Rectangle paintIconR = new Rectangle();
    Rectangle paintTextR = new Rectangle();
    Rectangle paintViewR = new Rectangle();
    Insets paintViewInsets = new Insets(0, 0, 0, 0);

    paintViewInsets = button.getInsets(paintViewInsets);
    paintViewR.x = paintViewInsets.left;
    paintViewR.y = paintViewInsets.top;
    paintViewR.width = button.getWidth() - (paintViewInsets.left + paintViewInsets.right);
    paintViewR.height = button.getHeight() - (paintViewInsets.top + paintViewInsets.bottom);

    Graphics g = button.getGraphics();
    if (g == null) {
        return null;
    }
        SwingUtilities.layoutCompoundLabel(button,
                                           g.getFontMetrics(),
                                           text,
                                           icon,
                                           button.getVerticalAlignment(),
                                           button.getHorizontalAlignment(),
                                           button.getVerticalTextPosition(),
                                           button.getHorizontalTextPosition(),
                                           paintViewR,
                                           paintIconR,
                                           paintTextR,
                                           button.getIconTextGap());

    return paintTextR;
}
 
源代码11 项目: openjdk-8-source   文件: ConnectDialog.java
private static Rectangle getTextRectangle(AbstractButton button) {
    String text = button.getText();
    Icon icon = (button.isEnabled()) ? button.getIcon() : button.getDisabledIcon();

    if (icon == null && button.getUI() instanceof BasicRadioButtonUI) {
        icon = ((BasicRadioButtonUI)button.getUI()).getDefaultIcon();
    }

    if ((icon == null) && (text == null)) {
        return null;
    }

    Rectangle paintIconR = new Rectangle();
    Rectangle paintTextR = new Rectangle();
    Rectangle paintViewR = new Rectangle();
    Insets paintViewInsets = new Insets(0, 0, 0, 0);

    paintViewInsets = button.getInsets(paintViewInsets);
    paintViewR.x = paintViewInsets.left;
    paintViewR.y = paintViewInsets.top;
    paintViewR.width = button.getWidth() - (paintViewInsets.left + paintViewInsets.right);
    paintViewR.height = button.getHeight() - (paintViewInsets.top + paintViewInsets.bottom);

    Graphics g = button.getGraphics();
    if (g == null) {
        return null;
    }
        SwingUtilities.layoutCompoundLabel(button,
                                           g.getFontMetrics(),
                                           text,
                                           icon,
                                           button.getVerticalAlignment(),
                                           button.getHorizontalAlignment(),
                                           button.getVerticalTextPosition(),
                                           button.getHorizontalTextPosition(),
                                           paintViewR,
                                           paintIconR,
                                           paintTextR,
                                           button.getIconTextGap());

    return paintTextR;
}
 
源代码12 项目: openjdk-8   文件: ConnectDialog.java
private static Rectangle getTextRectangle(AbstractButton button) {
    String text = button.getText();
    Icon icon = (button.isEnabled()) ? button.getIcon() : button.getDisabledIcon();

    if (icon == null && button.getUI() instanceof BasicRadioButtonUI) {
        icon = ((BasicRadioButtonUI)button.getUI()).getDefaultIcon();
    }

    if ((icon == null) && (text == null)) {
        return null;
    }

    Rectangle paintIconR = new Rectangle();
    Rectangle paintTextR = new Rectangle();
    Rectangle paintViewR = new Rectangle();
    Insets paintViewInsets = new Insets(0, 0, 0, 0);

    paintViewInsets = button.getInsets(paintViewInsets);
    paintViewR.x = paintViewInsets.left;
    paintViewR.y = paintViewInsets.top;
    paintViewR.width = button.getWidth() - (paintViewInsets.left + paintViewInsets.right);
    paintViewR.height = button.getHeight() - (paintViewInsets.top + paintViewInsets.bottom);

    Graphics g = button.getGraphics();
    if (g == null) {
        return null;
    }
        SwingUtilities.layoutCompoundLabel(button,
                                           g.getFontMetrics(),
                                           text,
                                           icon,
                                           button.getVerticalAlignment(),
                                           button.getHorizontalAlignment(),
                                           button.getVerticalTextPosition(),
                                           button.getHorizontalTextPosition(),
                                           paintViewR,
                                           paintIconR,
                                           paintTextR,
                                           button.getIconTextGap());

    return paintTextR;
}
 
源代码13 项目: jdk8u_jdk   文件: ConnectDialog.java
private static Rectangle getTextRectangle(AbstractButton button) {
    String text = button.getText();
    Icon icon = (button.isEnabled()) ? button.getIcon() : button.getDisabledIcon();

    if (icon == null && button.getUI() instanceof BasicRadioButtonUI) {
        icon = ((BasicRadioButtonUI)button.getUI()).getDefaultIcon();
    }

    if ((icon == null) && (text == null)) {
        return null;
    }

    Rectangle paintIconR = new Rectangle();
    Rectangle paintTextR = new Rectangle();
    Rectangle paintViewR = new Rectangle();
    Insets paintViewInsets = new Insets(0, 0, 0, 0);

    paintViewInsets = button.getInsets(paintViewInsets);
    paintViewR.x = paintViewInsets.left;
    paintViewR.y = paintViewInsets.top;
    paintViewR.width = button.getWidth() - (paintViewInsets.left + paintViewInsets.right);
    paintViewR.height = button.getHeight() - (paintViewInsets.top + paintViewInsets.bottom);

    Graphics g = button.getGraphics();
    if (g == null) {
        return null;
    }
        SwingUtilities.layoutCompoundLabel(button,
                                           g.getFontMetrics(),
                                           text,
                                           icon,
                                           button.getVerticalAlignment(),
                                           button.getHorizontalAlignment(),
                                           button.getVerticalTextPosition(),
                                           button.getHorizontalTextPosition(),
                                           paintViewR,
                                           paintIconR,
                                           paintTextR,
                                           button.getIconTextGap());

    return paintTextR;
}
 
源代码14 项目: jdk8u-jdk   文件: ConnectDialog.java
private static Rectangle getTextRectangle(AbstractButton button) {
    String text = button.getText();
    Icon icon = (button.isEnabled()) ? button.getIcon() : button.getDisabledIcon();

    if (icon == null && button.getUI() instanceof BasicRadioButtonUI) {
        icon = ((BasicRadioButtonUI)button.getUI()).getDefaultIcon();
    }

    if ((icon == null) && (text == null)) {
        return null;
    }

    Rectangle paintIconR = new Rectangle();
    Rectangle paintTextR = new Rectangle();
    Rectangle paintViewR = new Rectangle();
    Insets paintViewInsets = new Insets(0, 0, 0, 0);

    paintViewInsets = button.getInsets(paintViewInsets);
    paintViewR.x = paintViewInsets.left;
    paintViewR.y = paintViewInsets.top;
    paintViewR.width = button.getWidth() - (paintViewInsets.left + paintViewInsets.right);
    paintViewR.height = button.getHeight() - (paintViewInsets.top + paintViewInsets.bottom);

    Graphics g = button.getGraphics();
    if (g == null) {
        return null;
    }
        SwingUtilities.layoutCompoundLabel(button,
                                           g.getFontMetrics(),
                                           text,
                                           icon,
                                           button.getVerticalAlignment(),
                                           button.getHorizontalAlignment(),
                                           button.getVerticalTextPosition(),
                                           button.getHorizontalTextPosition(),
                                           paintViewR,
                                           paintIconR,
                                           paintTextR,
                                           button.getIconTextGap());

    return paintTextR;
}
 
源代码15 项目: jdk8u-dev-jdk   文件: ConnectDialog.java
private static Rectangle getTextRectangle(AbstractButton button) {
    String text = button.getText();
    Icon icon = (button.isEnabled()) ? button.getIcon() : button.getDisabledIcon();

    if (icon == null && button.getUI() instanceof BasicRadioButtonUI) {
        icon = ((BasicRadioButtonUI)button.getUI()).getDefaultIcon();
    }

    if ((icon == null) && (text == null)) {
        return null;
    }

    Rectangle paintIconR = new Rectangle();
    Rectangle paintTextR = new Rectangle();
    Rectangle paintViewR = new Rectangle();
    Insets paintViewInsets = new Insets(0, 0, 0, 0);

    paintViewInsets = button.getInsets(paintViewInsets);
    paintViewR.x = paintViewInsets.left;
    paintViewR.y = paintViewInsets.top;
    paintViewR.width = button.getWidth() - (paintViewInsets.left + paintViewInsets.right);
    paintViewR.height = button.getHeight() - (paintViewInsets.top + paintViewInsets.bottom);

    Graphics g = button.getGraphics();
    if (g == null) {
        return null;
    }
        SwingUtilities.layoutCompoundLabel(button,
                                           g.getFontMetrics(),
                                           text,
                                           icon,
                                           button.getVerticalAlignment(),
                                           button.getHorizontalAlignment(),
                                           button.getVerticalTextPosition(),
                                           button.getHorizontalTextPosition(),
                                           paintViewR,
                                           paintIconR,
                                           paintTextR,
                                           button.getIconTextGap());

    return paintTextR;
}
 
 类所在包
 类方法
 同包方法