File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Swing / AWT / SWT and the fly likes Is possible change icon of Ok's botton in JOPtionPane, How? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Is possible change icon of Ok Watch "Is possible change icon of Ok New topic
Author

Is possible change icon of Ok's botton in JOPtionPane, How?

Daniel Faria
Greenhorn

Joined: Dec 25, 2007
Posts: 15
Is possible change icon of Ok's botton in JOPtionPane, How?

Thanks.
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
> Is possible change icon of Ok's botton in JOPtionPane, How?

as far as I know, the 'OK' button only has text.

can you post an example of one with the icon you want changed
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19543
    
  16

Michael Dunn wrote:> Is possible change icon of Ok's botton in JOPtionPane, How?

as far as I know, the 'OK' button only has text.

Perhaps the look&feel adds an icon to that. In GTK for instance it's quite normal to have a little check icon (v) on the OK button, and an X on the Cancel button.

I've checked the source of JOptionPane and BasicOptionPaneUI, and I think you can do this by using the showOptionPane method, providing your own custom buttons to the method as the options. You'll need to handle which button was clicked manually. For instance:
Daniel Faria
Greenhorn

Joined: Dec 25, 2007
Posts: 15
But in my case is showMessageDialog.
It's possible??

Thanks.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19543
    
  16

showMessageDialog, and all other methods, eventually delegate to showOptionDialog.

A part of JOptionPane's source:
Just use the same as the last one but with your custom options.
 
 
subject: Is possible change icon of Ok's botton in JOPtionPane, How?
 
Similar Threads
JOptionPane
JOptionPane
Changing border color in JOptionPane
JOptionPane question
How To Change the Title Icon of JoptionPane/dialog