javax.swing.plaf.basic.BasicRadioButtonUI Java Examples

The following examples show how to use javax.swing.plaf.basic.BasicRadioButtonUI. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CheckBoxList.java    From consulo with Apache License 2.0 5 votes vote down vote up
@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());
}
 
Example #2
Source File: JBCheckBox.java    From consulo with Apache License 2.0 5 votes vote down vote up
/**
 * 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;
}
 
Example #3
Source File: ConnectDialog.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
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;
}
 
Example #4
Source File: ConnectDialog.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
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;
}
 
Example #5
Source File: ConnectDialog.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
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;
}
 
Example #6
Source File: ConnectDialog.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
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;
}
 
Example #7
Source File: ConnectDialog.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
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;
}
 
Example #8
Source File: ConnectDialog.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
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;
}
 
Example #9
Source File: ConnectDialog.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
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;
}
 
Example #10
Source File: ConnectDialog.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
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;
}
 
Example #11
Source File: ConnectDialog.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
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;
}
 
Example #12
Source File: ConnectDialog.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
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;
}
 
Example #13
Source File: ConnectDialog.java    From jdk8u_jdk with GNU General Public License v2.0 4 votes vote down vote up
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;
}
 
Example #14
Source File: ConnectDialog.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
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;
}
 
Example #15
Source File: ConnectDialog.java    From jdk8u-dev-jdk with GNU General Public License v2.0 4 votes vote down vote up
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;
}