This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
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


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
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: 19672
    
  18

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: 19672
    
  18

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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Is possible change icon of Ok's botton in JOPtionPane, How?