自定義按鈕不能在mac上工作(ButtonUI)我有一個(gè)應(yīng)用程序,它使用遍布文本和圖標(biāo)的自定義按鈕。適用于Windows和Linux,但現(xiàn)在OSX用戶抱怨。文本不會(huì)顯示在Mac上,只是'...'。代碼看起來很簡單,但是當(dāng)涉及到mac時(shí)我很無能為力。我怎樣才能解決這個(gè)問題?測試用例: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!");
}
});
添加回答
舉報(bào)
0/150
提交
取消