Java Code Examples for javax.swing.plaf.basic.BasicRadioButtonUI

The following examples show how to use javax.swing.plaf.basic.BasicRadioButtonUI. These examples are extracted from open source projects. 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 Project: consulo   Source File: CheckBoxList.java    License: 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 Project: consulo   Source File: JBCheckBox.java    License: 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
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 Project: TencentKona-8   Source File: ConnectDialog.java    License: 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 Project: jdk8u60   Source File: ConnectDialog.java    License: 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 Project: openjdk-jdk8u   Source File: ConnectDialog.java    License: 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
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 Project: openjdk-jdk9   Source File: ConnectDialog.java    License: 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 Project: jdk8u-jdk   Source File: ConnectDialog.java    License: 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 Project: hottub   Source File: ConnectDialog.java    License: 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
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 Project: openjdk-8   Source File: ConnectDialog.java    License: 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 Project: jdk8u_jdk   Source File: ConnectDialog.java    License: 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 Project: jdk8u-jdk   Source File: ConnectDialog.java    License: 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 Project: jdk8u-dev-jdk   Source File: ConnectDialog.java    License: 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;
}