aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes Is it possible to simply change the optionType label in JOptionPane 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 it possible to simply change the optionType label in JOptionPane" Watch "Is it possible to simply change the optionType label in JOptionPane" New topic
Author

Is it possible to simply change the optionType label in JOptionPane

Esmaeil Ashrafi
Ranch Hand

Joined: Feb 22, 2010
Posts: 73
Hi all
I am aware of possibility to have an array of objects (usually Strings) as the parameter options, so we can have buttons with custom labels.
Is there any easier way to just for example change the value of OK_OPTION option button label/text from "ok" to "okAy" ?

Thanks in advance


I'm really tired of being engaged with stuff other than Java and programming

Wish to get back soon to my love...
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10255
    
    8

Whats wrong with the existing way of changing the button text?


[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
Esmaeil Ashrafi
Ranch Hand

Joined: Feb 22, 2010
Posts: 73
Maneesh Godbole wrote:Whats wrong with the existing way of changing the button text?

I am talking about JOptionPane !
please consider this :

i want to see whether is there any way not to use options and have just one option same OK_OPTION but with different text than "ok" !
I checked the documentations, there is no such methods something like setOK_OPTIONvalue(String customLabel), i also checked the source code of JOptionPane to find where this value is made, but didn't find (i wanted to subclass JOptionPane and change the value of default optionType(s) such as OK_OPTION or OK_CANCEL_OPTION designate)
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19670
    
  18

You can use UIManager to override these values. For instance:
You can set the value for "OptionPane.okButtonText" for the OK button. But be warned, this will affect all option panes, not just the current one. I would just use showOptionPane with that one button, possibly wrapped in a static utility method:


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Esmaeil Ashrafi
Ranch Hand

Joined: Feb 22, 2010
Posts: 73

That was just great !

And also i needed to override the value for all panes to fit in my native language,Farsi,no problem to affect all optionPanes, i can use options[] wherever more specific option needed

I think this is the time to study on UIManager docs precisely

Thnk you
 
wood burning stoves
 
subject: Is it possible to simply change the optionType label in JOptionPane