Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to select text in a Custom JSpinner

 
RajivR Singh
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
> 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
Pie
Posts: 20669
65
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How about ft.selectAll(), without using the Formatter?
 
Maneesh Godbole
Saloon Keeper
Posts: 11196
15
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JFormattedTextField inherits the selectAll method from JTextComponent
 
RajivR Singh
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
> 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
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes. with timer its working.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic