Pradeep
Pradeep

Reputation: 2497

Customizing JOptionPane

We are trying to customize a JOptionPane generated JDialog to have rounded corners. We have a JPanel implementation that has rounded corners. I am unable to find a way to integrate the rounded corners implementation into the JOptionPane/JDialog.

It would of great help if some one can point me into how I can fit the JDialog into a JPanel or some other way to do this.

Upvotes: 0

Views: 455

Answers (2)

Mordechai
Mordechai

Reputation: 16294

A JDialog is a top level component that can not be added anywhere. Although you can add the "content" of the JOptionPane, by using one of JOptionPane's constructors .

Upvotes: 2

MadProgrammer
MadProgrammer

Reputation: 347334

JOptionPane extends from JComponent. It provides convince methods to construct the JDialog which is displayed on the screen (containing an instance of JOptionPane)

If you want to modify the look and feel of the JDialog, you need to create your own undecorated dialog and add the JOptionPane to it.

What I would suggest would be to create a number of static utility methods that mimic the JOptionPane showXxxMessage methods but which create the instance of the dialog you want and which then simply add an instance of the JOptionPane to.

You will need to attach a PropertyChangeListener to the JOptionPane to monitor when the user makes a selection though.

Upvotes: 2

Related Questions