![](/img/trans.png)
[英]Combobox ArrowButton is strecthing respective to the font size in nimbus LaF
[英]JOptionPane button size (Nimbus LAF)
最近我一直在與Nimbus Look and Feel一起開展Swing項目。 我想將JOptionPane中的所有按鈕設置為具有相同的大小,但是徒勞無功。
import javax.swing.*;
public class NimbusTest {
public static void main(String[] args) {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
try {
for (UIManager.LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
if (("Nimbus").equals(info.getName())) {
UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (Exception ex) {
ex.printStackTrace();
}
UIManager.put("OptionPane.sameSizeButtons", true);
String[] options = new String[]{"--------------------","short","1"};
int option = JOptionPane.showOptionDialog(null, "Nimbus problem", "JOptionPane", JOptionPane.DEFAULT_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, options[1]);
}
});
}
}
我想要的是一個JOptionPane,其中三個按鈕具有相同的大小。 但是,我得到了以下結果:
我的代碼UIManager.put("OptionPane.sameSizeButtons", true);
似乎被忽略了。 如果我不想重新創建類似JOptionPane的對話框,我該怎么做才能創建具有相同大小按鈕的JOptionPane?
更換
UIManager.put("OptionPane.sameSizeButtons", true);
同
UIManager.getLookAndFeelDefaults().put("OptionPane.sameSizeButtons", true);
它就像一個魅力
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.