Java Utililty Methods JButton Settings

List of utility methods to do JButton Settings

Description

The list of methods to do JButton Settings are organized into topic(s).

Method

voidstyleButton(final AbstractButton btn)
style Button
btn.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2));
btn.setMinimumSize(new Dimension(BUTTON_SIZE, BUTTON_SIZE));
btn.setPreferredSize(new Dimension(BUTTON_SIZE, BUTTON_SIZE));
btn.setSize(new Dimension(BUTTON_SIZE, BUTTON_SIZE));
btn.setRolloverEnabled(false);
btn.setFocusPainted(false);
btn.setFocusable(false);
btn.setContentAreaFilled(false);
...
TtoBold(final T button)
to Bold
final Font f = button.getFont();
button.setFont(f.deriveFont(f.getStyle() ^ Font.BOLD));
return button;
voidtryToBuildAFocusGroup(AbstractButton... buttons)
Tries to group the given buttons using the FocusTraversalUtils class - if available.
if (groupMethod == null) {
    return;
try {
    groupMethod.invoke(null, (Object) buttons);
} catch (IllegalAccessException | InvocationTargetException e) {
voidunifiedButtonLookAndFeel(JComponent b)
Sets the UI properties of the button to unify the L&F.
if (b == null)
    return;
b.setOpaque(false);
b.setBorder(new EmptyBorder(2, 2, 2, 2));
voidupdateSize(AbstractButton button, Dimension size)
update Size
Icon icon = button.getIcon();
if (icon != null) {
    size.width = Math.max(size.width, icon.getIconWidth());
    size.height = Math.max(size.height, icon.getIconHeight());
booleanuseOptimizedCustomButtonPainting()
If true, ButtonPanel will build a bitmap of the custom editor button to use when painting - huge amounts of painting time in XP and Aqua are used scaling the L&F's background button bitmap (and the custom editor button is always a fixed size), so this yields better performance when a large number of custom editor buttons are displayed.
if (useOptimizedCustomButtonPainting == null) {
    if ("Windows".equals(UIManager.getLookAndFeel().getID())) { 
        useOptimizedCustomButtonPainting = Boolean.valueOf(isXPTheme());
    } else {
        useOptimizedCustomButtonPainting = Boolean
                .valueOf("Aqua".equals(UIManager.getLookAndFeel().getID()));
return useOptimizedCustomButtonPainting.booleanValue();