views:

410

answers:

1

The text in my JOptionPanes are way to small I was wondering how I could change the font of the text inside the pane. Also, I would like to be set a space between two buttons.

Something like

   |Canecl|               |DoneSave| |Save|
+3  A: 

I guess you mean the fonts on your JButtons inside the JOptionPane are too small.

For that I suggest using Swing Utils by Darryl Burke. Now you can easily do e.g.

for (JButton button : SwingUtils.getDescendantsOfType(JButton.class, pane)) {
    button.setFont(new Font("Verdana", Font.BOLD, 32));
}

to set the fonts on all JButtons inside of JOptionPane pane.

If you want to set the font of the JOptionPane message itself, use e.g.

UIManager.put(
    "OptionPane.messageFont",
    new FontUIResource(new Font("Verdana", Font.BOLD, 32))
);

In regard to the "spacing of buttons" question: I don't know if that can be done without extending & make a customized JOptionPane yourself.

jitter
Thank You very much!
Saher