自定义按钮不能在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 static 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!");
}
});
添加回答
举报
0/150
提交
取消