0
因此,我在我寫的Java程序中有幾個JButton,它顯然包含一個值(如在按鈕上出現的文本中)。JButton的值總是適合Windows中的按鈕,但不適用於Linux
當我在Windows中運行應用程序時,這個文本總是適合在JButton中 - 無論窗口有多小(我爲該窗口設置了最小尺寸)。但是,當我在Linux中運行應用程序時,文本似乎不適合按鈕。
我定義我的Jbutton將是這樣的:
public class ButtonPanel extends JPanel {
private JButton undoButton;
/**
* Button panel constructor.
*/
public ButtonPanel() {
// Set the layout
this.setLayout(new FlowLayout(FlowLayout.CENTER, 10, 5));
// Add all buttons and register their listeners
undoButton = new JButton("Undo");
undoButton.setPreferredSize(new Dimension(100, 50));
undoButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
System.out.println("Undo button pressed");
try {
App.performActivity(Activity.UNDO);
} catch (Exception e1) {
e1.printStackTrace();
}
}
});
this.add(undoButton);
}
有沒有人有什麼想法?
謝謝
卡勒姆
絕對正確!非常感謝。 – Callum