views:

23

answers:

1

The line of code below displays a dialog box with two buttons: Yes and No. I want those two buttons to be at least 3 times the actual default size. I understand I can create a customized JFrame and add button and set the Size but I have scores of dialog boxes; does not seems practical.

JOptionPane.showConfirmDialog(null, "Did you eat", "Confirmation", JOptionPane.YES_NO_OPTION);

The reason why I want to make the buttons larger is because I increased the font size of the dialog boxes (one line of code impacted all the dialog boxes in my code). And the small (default) size of the buttons look akward now compared to the the verbage.

So how can I manipulate JOptionPane dialog box's button's sizes?

A: 

Adding this before the dialog boxes, will change the font of the button's text; thereby, inreasing the button's dimensions. Make sure to import this:

import java.awt.Font; 
import javax.swing.plaf.FontUIResource; 




UIManager.put("OptionPane.buttonFont", new FontUIResource(new Font("ARIAL",Font.PLAIN,35))); 

If want to have different font for a specific dialog box, and then go back to the one you were using, all you have to do is put that line of code and change the font size. then after the dialog box, put the original one back. It kind of overrides it each time you do it.

Faraz Khan