Author
How to select text in a Custom JSpinner
RajivR Singh
Greenhorn
Joined: Aug 31, 2009
Posts: 5
Hi,
i have a Custom Jspinner in a dialog box which i uses to show some string . i wanted to select this text when ever dialog box is called.
i am using foloowing code for the same but its not working.
Michael Dunn
Ranch Hand
Joined: Jun 09, 2003
Posts: 4632
posted Aug 31, 2009 04:45:55
0
> i am using foloowing code for the same but its not working.
"but its not working. " implies that it compiles and runs OK, but doesn't achieve the desired result.
I couldn't get your version to compile (please show us how you did it),
but my version of a 'compiled OK' selectAll() works fine.
so, get yours to compile and run, and it should work for you as well.
Rob Spoor
Sheriff
Joined: Oct 27, 2005
Posts: 19232
How about ft.selectAll(), without using the Formatter?
SCJP 1.4 - SCJP 6 - SCWCD 5
How To Ask Questions How To Answer Questions
Maneesh Godbole
Saloon Keeper
Joined: Jul 26, 2007
Posts: 8565
JFormattedTextField inherits the selectAll method from JTextComponent
[Donate a pint, save a life! ] [How to ask questions ] [Onff-turn it on! ]
RajivR Singh
Greenhorn
Joined: Aug 31, 2009
Posts: 5
Thanks for Reply guys.
but i still finds same problem. mean while i noticed that my text field is getting selected and then selection is getting lost. this i noticed by giving some delay.
also i notice that there is a bug filed with Sun in 1.4 version related to this.
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4699955
i am using 1.5 version.
Michael Dunn
Ranch Hand
Joined: Jun 09, 2003
Posts: 4632
posted Aug 31, 2009 17:41:44
0
> mean while i noticed that my text field is getting selected and then selection is getting lost.
try using a timer
note: if the dialog is modal, you need this code prior to dialog.setVisible(true);
RajivR Singh
Greenhorn
Joined: Aug 31, 2009
Posts: 5
Yes. with timer its working.
subject: How to select text in a Custom JSpinner