Пользовательская кнопка не работает на Mac (ButtonUI)

У меня есть приложение, которое использует пользовательские кнопки повсюду для текста и значков. Отлично работает для Windows и Linux, но теперь пользователи OSX жалуются. Текст не отображается на Mac, просто «...». Код кажется достаточно простым, но я не знаю, когда дело доходит до Mac. Как я могу это исправить?

Прецедент:

package example.swingx;
import example.utils.ResourceLoader;
import com.xduke.xlayouts.XTableLayout;    
import javax.swing.*;
import javax.swing.plaf.ComponentUI;
import java.awt.*;
import java.awt.event.ActionEvent;

public class SmallButton extends JButton {
    private st,atic ComponentUI ui = new SmallButtonUI();
    public SmallButton() {
        super();
        /*  final RepaintManager repaintManager = RepaintManager.currentManager(this);
        repaintManager.setDoubleBufferingEnabled(false);
        setDebugGraphicsOptions(DebugGraphics.FLASH_OPTION);*/
    }
    public SmallButton(AbstractAction action) {
        super(action);
    }
    public SmallButton(String text) {
        super(text);
    }
    public SmallButton(Icon icon) {
        super(icon);
    }
    public void updateUI() {
        setUI(ui);
    }

    public static void main(String[] args) {
        JFrame frame = new JFrame();
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

        final JPanel buttonPanel = new JPanel(new XTableLayout());
        SmallButton firstSmallButton = new SmallButton("One");
        SmallButton secondSmallButton = new SmallButton("Two");
        SmallButton thirdSmallButton = new SmallButton();

        ImageIcon cameraIcon = (ImageIcon) ResourceLoader.getIcon("camera");
        SmallButton fourth = new SmallButton();

        fourth.setAction(new AbstractAction() {
            public void actionPerformed(ActionEvent e) {
                System.out.println("Fourth button pressed!");
            }
        });
        fourth.setIcon(cameraIcon);

        buttonPanel.add(firstSmallButton, "+");
        buttonPanel.add(secondSmallButton, "+");
        buttonPanel.add(thirdSmallButton, "+");
        buttonPanel.add(fourth, "+");

        final Container container = frame.getContentPane();
        container.add(buttonPanel);
        frame.pack();
        frame.setVisible(true);
    }
}

UI:

package example.swingx;

import javax.swing.*;
import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.basic.BasicButtonUI;
import java.awt.*;

public class SmallButtonUI extends BasicButtonUI {
    private static final Color FOCUS_COLOR = new Color(0, 0, 0);
    private static final Color BACKGROUND_COLOR = new Color(173, 193, 226);
    private static final Color SELECT_COLOR = new Color(102, 132, 186);
    private static final Color DISABLE_TEXT_COLOR = new Color(44, 44, 61);
    private static final Insets DEFAULT_SMALLBUTTON_MARGIN = new Insets(2, 4, 2, 4);

    private final static SmallButtonUI smallButtonUI = new SmallButtonUI();

    public static ComponentUI createUI(JComponent component) {
        return smallButtonUI;
    }
    protected Color getSelectColor() {
        return SELECT_COLOR;
    }
    protected Color getDisabledTextColor() {
        return DISABLE_TEXT_COLOR;
    }
    protected Color getFocusColor() {
        return FOCUS_COLOR;
    }

    public void paint(Graphics g, JComponent c) {
        ((Graphics2D) g).setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
        super.paint(g, c);
    }

    protected void paintButtonPressed(Graphics graphics, AbstractButton button) {
        if (button.isContentAreaFilled()) {
            Dimension size = button.getSize();
            graphics.setColor(getSelectColor());
            graphics.fillRect(0, 0, size.width, size.height);
        }
    }

    public Dimension getMinimumSize(JComponent component) {
        final AbstractButton button = ((AbstractButton) component);

        // Handle icon buttons:
        Icon buttonIcon = button.getIcon();
        if (buttonIcon != null) {
            return new Dimension(
                    buttonIcon.getIconWidth(),
                    buttonIcon.getIconHeight()
            );
        }

        // Handle text buttons:
        final Font fontButton = button.getFont();
        final FontMetrics fontMetrics = button.getFontMetrics(fontButton);
        final String buttonText = button.getText();
        if (buttonText != null) {
            final int buttonTextWidth = fontMetrics.stringWidth(buttonText);
            return new Dimension(buttonTextWidth + 15,
                    fontMetrics.getHeight() + 5);
        }
        return null;
    }

    protected void installDefaults(AbstractButton button) {
        super.installDefaults(button);
        button.setMargin(DEFAULT_SMALLBUTTON_MARGIN);
        button.setBackground(getBackgroundColor());
    }
    private Color getBackgroundColor() {
        return BACKGROUND_COLOR;
    }
    public Dimension getPreferredSize(JComponent component) {
        return getMinimumSize(component);
    }
    public Dimension getMaximumSize(JComponent component) {
        return super.getMinimumSize(component);
    }
    public SmallButtonUI() {
        super();
    }
}

РЕДАКТИРОВАТЬ: После отладки, кажется, getMinimumSize () одинаково на обеих платформах. Кроме того, когда я останавливаюсь в любом месте, где используется графика, кажется, что у mac значение transY равно 47, а у linux - 0. Эти 47, похоже, также подаются в области отсечения. Где это может быть установлено? \ Почему бы не использовать

Ответы на вопрос(1)

Ваш ответ на вопрос