Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / January 2008

Tip: Looking for answers? Try searching our database.

how to hide and show cursor in JTextField?

Thread view: 
Roy - 04 Jan 2008 01:05 GMT
Hi,

Is there any way to hide the cursor in the JTextField and show the
cursor when I click this field?  It'd be great if I click other area
or components in the panel, hide the cursor in the JTextField again.

Thanks a lot.
Roy
Mark Space - 04 Jan 2008 01:57 GMT
> Hi,
>
[quoted text clipped - 4 lines]
> Thanks a lot.
> Roy

Which cursor?  Mouse?  Insert caret?
Roy - 04 Jan 2008 04:13 GMT
> > Hi,
>
[quoted text clipped - 6 lines]
>
> Which cursor?  Mouse?  Insert caret?

It is the insert caret.
Andrew Thompson - 04 Jan 2008 04:35 GMT
...
>It is the insert caret.

Your comments do not make much sense to me.

There is an applet here that will pop a dialog with a
JTextField and JTextArea (click the 'Input' button).
<http://www.physci.org/test/resize/>

The 'insert caret' (as I understand it) will only show in
the text field/area that currently has focus, in either the
Metal or System (Win) PLAFs.

To hide the insert caret even when it is in a particular
text widget, just set the widget uneditable or disabled
(see dropdown on main applet GUI).

Signature

Andrew Thompson
http://www.physci.org/

Roy - 04 Jan 2008 05:12 GMT
> ..
>
[quoted text clipped - 18 lines]
>
> Message posted viahttp://www.javakb.com

Thanks a lot. I happened to setFocusable(false) for all other
components. So the JTextField is the only component that always has
focus. That is why the insert caret is always blinking.

Anway, I was told by a friend that a simple way to hide the caret in
this situation is to do the following:

MyTextField.getCaret().setVisible(false);

Thanks again.
Roy
Mark Space - 04 Jan 2008 19:27 GMT
> MyTextField.getCaret().setVisible(false);

I was going to suggest the same thing Andrew did.  I didn't know about
this method, good find, thanks!


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.