This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
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 Murach's Java Servlets and JSP this week in the Servlets 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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Selecting Text and Positioning Cursor
 
Similar Threads
Displaying text in GUI'S.
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
Populate the 'current' JTextField via a button/label