![](/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.