• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Daniel Faria
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is possible change icon of Ok's botton in JOPtionPane, How?

Thanks.
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
> 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
Pie
Posts: 20527
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But in my case is showMessageDialog.
It's possible??

Thanks.
 
Rob Spoor
Sheriff
Pie
Posts: 20527
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic