• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Is it possible to simply change the optionType label in JOptionPane

 
Esmaeil Ashrafi
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Maneesh Godbole
Saloon Keeper
Posts: 11096
13
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Whats wrong with the existing way of changing the button text?
 
Esmaeil Ashrafi
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 20610
63
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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:
 
Esmaeil Ashrafi
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic