Results 1 to 5 of 5
  1. #1
    Josep_16's Avatar
    Josep_16 is offline Member
    Join Date
    Mar 2011
    Posts
    40
    Rep Power
    0

    Default Make the TextField unable to write on

    Hello there! I was wondering if there was any kind of method that could make a TextField unable to write on it. It's an usual action of textfields in programs, when you select an option that makes the textfield grey-colored and unable to write on it. I'd like to know if there is a method that could perform this action in Java textfields. I hope there is one, thanks.

  2. #2
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    4,038
    Rep Power
    10

    Default

    Are you looking for the setEnabled() or setEditable() methods? Check out the API: JTextField (Java Platform SE 6)
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  3. #3
    Josep_16's Avatar
    Josep_16 is offline Member
    Join Date
    Mar 2011
    Posts
    40
    Rep Power
    0

    Default

    Quote Originally Posted by KevinWorkman View Post
    Are you looking for the setEnabled() or setEditable() methods? Check out the API: JTextField (Java Platform SE 6)
    Ye, right. Thanks!

  4. #4
    nagatron's Avatar
    nagatron is offline Java Program Blog
    Join Date
    Jul 2011
    Posts
    2
    Rep Power
    0

    Default

    Java Code:
    JTextField field = new JTextField();
    field.setEditable(true); //if you want to put text in it
    field.setEditable(false); //if you want to deactivate the textfield and make it uneditable which means you can't type.

  5. #5
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,458
    Rep Power
    20

    Default

    Quote Originally Posted by nagatron View Post
    Java Code:
    JTextField field = new JTextField();
    field.setEditable(true); //if you want to put text in it
    field.setEditable(false); //if you want to deactivate the textfield and make it uneditable which means you can't type.
    Superfluous response in an adequately answered thread.

    nagatron, several posts of yours have been deleted as spam. If you persist in making useless posts, you will be banned.

    You may consider this a first and final warning.

    db

Similar Threads

  1. Replies: 3
    Last Post: 07-06-2011, 01:50 PM
  2. Unable to write/post to a URL from Java
    By achab in forum Advanced Java
    Replies: 38
    Last Post: 11-06-2010, 02:21 AM
  3. Unable to create and write files
    By DrKilljoy in forum New To Java
    Replies: 4
    Last Post: 09-05-2010, 01:55 AM
  4. How to make Swing JTextField look like AWT TextField?
    By LeonLanford in forum AWT / Swing
    Replies: 1
    Last Post: 09-04-2010, 05:06 PM
  5. how to make window active and textfield focused
    By whwillisiv in forum New To Java
    Replies: 0
    Last Post: 04-28-2009, 05:06 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •