File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Swing / AWT / SWT and the fly likes Selecting Text and Positioning Cursor Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Selecting Text and Positioning Cursor" Watch "Selecting Text and Positioning Cursor" New topic
Author

Selecting Text and Positioning Cursor

Lou Pelagalli
Ranch Hand

Joined: Nov 11, 2003
Posts: 150
    
    1
Hi,
I'm trying jTextField.select(int, int) and jTextField.selectAll() to highlight data in error, and neither will work. I even tried jTextField.setSelectedTextColor(Color.red); to be sure I would have a contrasting color, still doesn't work.
Can anyone help me get this working?
Also, can anywone tell me how to move the cursor to the JTextField in error without selecting any text?
Thank You in Advance for Your Help,
Lou
Lou Pelagalli
Ranch Hand

Joined: Nov 11, 2003
Posts: 150
    
    1
As frequently happens, five minutes after I post a question I discover the answer.
jTextField.requestFocus();
jTextField.selectAll(); or jTextField.select(int, int);
To move the cursor only
jTextField.requestFocus();
Happy Coding,
Lou
 
jQuery in Action, 2nd edition
 
subject: Selecting Text and Positioning Cursor
 
Similar Threads
Displaying text in GUI'S.
Populate the 'current' JTextField via a button/label
the JDBC "invalid state cursor" error
Text controls don't work properly in child Java window
How to change cursor height based on Font size