Results 1 to 2 of 2
  1. #1
    Join Date
    Mar 2011
    Posts
    52
    Rep Power
    0

    Default How to Enable and Disable JtextField on Selection of Checkbox

    Hi All,
    I Need to Enable the textbox only when my check box is selected else it will be disable. can i set that text box Editable.

    Java Code:
    boolean chkbox=jCheckBox1.isSelected();
            if (chkbox= true)
         {
       jTextField1.setEnabled(true);
    }
    I am trying above code, is there any other thing ?

    Please Help me where i am Wrong....

  2. #2
    lovelesh is offline Senior Member
    Join Date
    Nov 2010
    Location
    Delhi
    Posts
    135
    Blog Entries
    1
    Rep Power
    0

    Smile

    Use addActionListener api of JCheckBox for this.

    You will have to provide an implementation of ActionListener interface.

    In the actionPerformed method of ActionListener implementation, you need to write your logic.
    Something like which you have written in your post.

    Try on your own and if still you are stuck, then come back.

Similar Threads

  1. Disable a checkbox in jtable
    By pink123 in forum AWT / Swing
    Replies: 8
    Last Post: 03-24-2011, 06:29 PM
  2. Please help : JSP enable/disable button
    By kalyana in forum New To Java
    Replies: 3
    Last Post: 03-24-2011, 05:06 PM
  3. Replies: 3
    Last Post: 07-27-2010, 09:52 AM
  4. use javascript to enable/disable hyperlinks
    By sauravsinha in forum JavaServer Pages (JSP) and JSTL
    Replies: 4
    Last Post: 04-22-2010, 06:04 PM
  5. How to use "selectOneRadio" to enable/disable a Picklist
    By vivekbakshi in forum JavaServer Faces (JSF)
    Replies: 1
    Last Post: 04-07-2008, 03:14 PM

Posting Permissions

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