Note that there are some explanatory texts on larger screens.

plurals
  1. POJava Swing JOptionPane Yes and No Button differ in font size after setting Nimbus LookandFeel
    primarykey
    data
    text
    <p>Since the font size is too small in default <strong>LookAndFeel</strong>, I used a few lines of code to set it to <strong>Nimbus</strong>, and my <strong>JOptionPane</strong> shows <em>Yes</em> and <em>No</em> button with different size. <em>Yes</em> is still very small, while <em>No</em> is set to be with the size I assign it to be. Anybody knows why or how to fix it?</p> <pre><code>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); } </code></pre> <p>...</p> <pre><code>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() </code></pre> <p>The following line shows the option pane but it has <em>Yes</em> and <em>No</em> with different size. Is it normal or is it just my problem?</p> <pre><code>inputValuex=JOptionPane.showConfirmDialog( myWin, "Are you exiting?", "You clicked X", JOptionPane.YES_NO_OPTION); </code></pre> <h1><strong>Update</strong></h1> <p>Still not working. I have tried to use the code</p> <p><code>javax.swing.UIManager.put("OptionPane.isYesLast", true);</code> </p> <p>to change the location of the <em>Yes</em> button but it didn't have any effect. I just wanted to see how to set those values such as boolean.</p> <p>Also, I even listed all keys in <code>UIManager.getDefaults()</code> which contains <em>optionpane</em>, or <em>button</em>, and their font sizes are all set to 20. The <em>Yes</em> button still as smaller font.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload