This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
I wasn't sure if OptionPane.getOptions() returned an array of the buttons, or just the Strings, but when I tested it, it just returns 'null' unless you specifically set options yourself. You could get buttons from the BasicOptionPaneUI, but the method is protected, so it would be a pain to re-implement the entire OptionPaneUI just to get to this. You could also create your own buttons with the specified font, and pass them into the optionpane constructor as 'options' but then you'd have to implement the actionlisteners that should be attached to the buttons (option pane doesn't do this for you).
You could use a method like the following to get all the buttons, then go through the list and set the font on each one. This is really just hack (unfortunately though, I don't see a *good* way to do this). Pass the JButton.class class in and the option pane (or dialog, or internal frame created from the option pane). Then just go through the list you get back and call setFont() on each button.
Write once, run anywhere, because there's nowhere to hide! - /. A.C.
Joined: Feb 26, 2003
Thank you Nathan, I think a better way is to create my own dialog.