Since the font size is too small in default LookAndFeel, I used a few lines of code to set it to Nimbus, and my JOptionPane shows Yes and No button with different size. Yes is still very small, while No is set to be with the size I assign it to be. Anybody knows why or how to fix it?
public static void setUIFont(Font a){
FontUIResource ax=new FontUIResource(a);
javax.swing.UIManager.put("OptionPane.messageFont", ax);
javax.swing.UIManager.put("OptionPane.buttonFont", ax);
javax.swing.UIManager.put("OptionPane.Font", ax);
javax.swing.UIManager.put("InternalFrame.titleFont", ax);
javax.swing.UIManager.put("TextField.font", ax);
javax.swing.UIManager.put("ComboBox.font", ax);
}
...
UIManager.setLookAndFeel("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel");
class UseNimBus extends SwingInvoker{
public void run(){
JDialog.setDefaultLookAndFeelDecorated(true);
setUIFont(new FontUIResource(new Font(ufont, Font.PLAIN, 20)));
}
}
(new UseNimBus()).execute();// just invokeLater()
The following line shows the option pane but it has Yes and No with different size. Is it normal or is it just my problem?
inputValuex=JOptionPane.showConfirmDialog(
myWin, "Are you exiting?", "You clicked X", JOptionPane.YES_NO_OPTION);
Update
Still not working. I have tried to use the code
javax.swing.UIManager.put("OptionPane.isYesLast", true);
to change the location of the Yes button but it didn't have any effect. I just wanted to see how to set those values such as boolean.
Also, I even listed all keys in UIManager.getDefaults()
which contains optionpane, or button, and their font sizes are all set to 20. The Yes button still as smaller font.