aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes How to select text in a Custom JSpinner Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "How to select text in a Custom JSpinner" Watch "How to select text in a Custom JSpinner" New topic
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
> 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: 19696
    
  20

How about ft.selectAll(), without using the Formatter?


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10377
    
    8

JFormattedTextField inherits the selectAll method from JTextComponent


[How to ask questions] [Donate a pint, save a life!] [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
> 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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to select text in a Custom JSpinner