how to hide and show cursor in JTextField?

Discussion in 'Java' started by Roy, Jan 4, 2008.

  1. Roy

    Roy Guest

    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
     
    Roy, Jan 4, 2008
    #1
    1. Advertising

  2. Roy

    Mark Space Guest

    Roy wrote:
    > 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


    Which cursor? Mouse? Insert caret?
     
    Mark Space, Jan 4, 2008
    #2
    1. Advertising

  3. Roy

    Roy Guest

    On Jan 3, 5:57 pm, Mark Space <> wrote:
    > Roy wrote:
    > > 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

    >
    > Which cursor? Mouse? Insert caret?


    It is the insert caret.
     
    Roy, Jan 4, 2008
    #3
  4. Roy wrote:
    ...
    >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).

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

    Message posted via http://www.javakb.com
     
    Andrew Thompson, Jan 4, 2008
    #4
  5. Roy

    Roy Guest

    On Jan 3, 8:35 pm, "Andrew Thompson" <u32984@uwe> wrote:
    > Roy wrote:
    >
    > ..
    >
    > >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).
    >
    > --
    > Andrew Thompsonhttp://www.physci.org/
    >
    > 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
     
    Roy, Jan 4, 2008
    #5
  6. Roy

    Mark Space Guest

    Roy wrote:

    > MyTextField.getCaret().setVisible(false);


    I was going to suggest the same thing Andrew did. I didn't know about
    this method, good find, thanks!
     
    Mark Space, Jan 4, 2008
    #6
  7. Roy

    Guest

    Excellent, thanks!
     
    , Aug 22, 2012
    #7
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?bWlrZWU=?=

    Cursor wait, hide or show

    =?Utf-8?B?bWlrZWU=?=, Dec 12, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    738
    Alex Papadimoulis
    Dec 12, 2003
  2. =?Utf-8?B?VG9tYXMgS2VwaWM=?=

    Changing DEFAULT cursor to WAIT cursor in ASP

    =?Utf-8?B?VG9tYXMgS2VwaWM=?=, Apr 5, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    2,329
    Bruce Barker
    Apr 5, 2005
  3. invy
    Replies:
    4
    Views:
    395
    CBFalconer
    Dec 28, 2006
  4. dmaziuk
    Replies:
    3
    Views:
    587
    Chris Gonnerman
    Jan 25, 2011
  5. ll
    Replies:
    2
    Views:
    653
    Thomas 'PointedEars' Lahn
    May 1, 2008
Loading...

Share This Page