1

Im using JOptionPane.showConfirmDialog() to create a window where Im asking, if the user really wants to close the program. I do not want to create for that window a new JDialog possibly in a new class which would be too complicated maybe.

Because Im often using a png-picture saved as a JLabel to be the background of the opened window, I wanted to ask, if there is a possibility to use a JLabel saved png-picture as background of the showconfirmDialog? Or is there any other possibility to change the value of the opened confirmDialog-Window such as Background-Color etc.?

user3133542
  • 1,695
  • 4
  • 21
  • 42
  • 1
    Typically when the programmer wants a component 'something like, but not quite' a `JOptionPane`, it is actually easier to create using a `JDialog`. Changing the functionality/look of a `JOptionPane` is a PITA. As to a BG color, look to change the PLAF. – Andrew Thompson Jun 21 '14 at 03:14

1 Answers1

1

The JavaDoc (http://docs.oracle.com/javase/7/docs/api/javax/swing/JOptionPane.html) says:

message

A descriptive message to be placed in the dialog box. In the most common usage, message is just a String or String constant. However, the type of this parameter is actually Object. Its interpretation depends on its type:

...

Component
    The Component is displayed in the dialog.

So the message can be any component, such as a JLabel. You can even add a JPanel with a more complicated layout.

Kris Scheibe
  • 361
  • 2
  • 5
  • +1 for the informative input :-) One related [example](http://stackoverflow.com/a/12235299/1057230) and [another](http://stackoverflow.com/a/17783405/1057230) for a quick reference :-) – nIcE cOw Jun 21 '14 at 05:26