### JOptionPane

##### Client properties:

Property | Type | Notes
--- | --- | ---
`Quaqua.OptionPane .destructiveOption` | `java.lang.Integer` | Specifies the index of the destructive option.

#### General

Quaqua displays JOptionPanes like a Mac OS X style alert.

Unfortunately lots of the visual elements are controlled by the application and not by the UI.

To perfectly follow Apple's Human Interface Guidelines for Dialogs, you should do the following:

- Replace the following icons in the Swing UIManager by a 64 x 64 pixel version of your application icon:
  OptionPane.errorIcon, OptionPane.informationIcon, OptionPane.questionIcon,
  OptionPane.warningIcon.
- Use Lucida Grande Bold 13 for the main message text and Lucida Grande Plain 11 for the information message text.
- Don't display a title on your option pane.
- Tell Quaqua which option is destructive, so that it can be placed at a distance to non-destructive options.
- Use JSheet where appropriate.

#### Replacing the OptionPane icons

Create a 64 x 64 pixel PNG version of your application icon, and replace the default JOptionPane icons. This is best done immediately after setting the look and feel.

UIManager.setLookAndFeel(QuaquaManager.getLookAndFeel()); Object appIcon = LookAndFeel.makeIcon( getClass(), "appicon.png" ); UIManager.put("OptionPane.errorIcon", appIcon); UIManager.put("OptionPane.informationIcon", appIcon); UIManager.put("OptionPane.questionIcon", appIcon); UIManager.put("OptionPane.warningIcon", appIcon);

#### Using appropriate fonts

One way to do this with minimal impact on the application logic, is putting a CSS style sheet into the UIManager, and using it whenever a dialog is created.

String css = "<head>"+ "<style type=\"text/css\">"+ "b { font: 13pt \"Lucida Grande\" }"+ "p { font: 11pt \"Lucida Grande\"; margin-top: 8px }"+ "</style>"+ "</head>"; UIManager.put("OptionPane.css", css);

Using this approach, you can specify a different CSS style sheet for each look and feel your application is using. Seen the code snippet below, on how to use this CSS style sheet.

#### Specifying the destructive option

If your option pane contains a destructive option, you should use the client property `Quaqua.OptionPane.destructiveOption` to specify its index using an Integer value.

The code snippet below makes use of the CSS style sheet we have defined above.

JOptionPane pane = new JOptionPane( "<html>"+UIManager.get("OptionPane.css")+ "<b>You have 4 documents with unsaved changes. "+ "Do you want to<br>"+ "review these changes before quitting?</b><p>"+ "If you don't review your documents, "+ "all your changes will be lost.", JOptionPane.QUESTION_MESSAGE ); Object[] options = { "Review Changes", "Cancel", "Discard Changes" }; pane.setOptions(options); pane.setInitialValue(options[0]); pane.putClientProperty( "Quaqua.OptionPane.destructiveOption", new Integer(2) ); JDialog dialog = pane.createDialog(null, null); dialog.show();

#### Specifying the width of the option pane

Quaqua uses the UIManager property `OptionPane.messageLabelWidth=360` to determine the width of HTML messages and `OptionPane.maxCharacterPerLineCount=60` to determine the width of text messages. You can change these values if they don't fit your requirements.