Results 1 to 3 of 3
  1. #1
    GUIJAVA is offline Member
    Join Date
    Feb 2010
    Posts
    2
    Rep Power
    0

    Default jcheckbox item listener (Solved)

    i hav tis itemlistener code for jcheckbox. when i click on the jcb, it shows true, which means the checkbox is ticked. when i untick the checkbox, it shows 2 lines, true & false. can any1 advice me which part of my code should i edit to make it print false only? im printing out the false & true to test my actionlistener only.

    public void itemStateChanged(ItemEvent e)
    {
    Object source = e.getItem();
    if (source == jcbenable)
    {
    jtfpriority1.setEditable(true);
    jtfpriority2.setEditable(true);
    b = true;
    System.out.println("true");
    }
    if (e.getStateChange() == ItemEvent.DESELECTED)
    {

    jtfpriority1.setEditable(false);
    jtfpriority2.setEditable(false);
    b = false;
    System.out.println("false");
    }
    }
    }
    Last edited by GUIJAVA; 02-09-2010 at 12:22 PM.

  2. #2
    RamyaSivakanth's Avatar
    RamyaSivakanth is offline Senior Member
    Join Date
    Apr 2009
    Location
    Chennai
    Posts
    797
    Rep Power
    6

    Default

    Have u added the itemlistener to the checkbox ?


    Please put complete code to understand fully.
    Ramya:cool:

  3. #3
    GUIJAVA is offline Member
    Join Date
    Feb 2010
    Posts
    2
    Rep Power
    0

    Default

    yes i hav added it to the checkbox. tat was y i gotten the result for the true & false.

    the output that was printed was:
    true (click once on the checkbox)
    true (untick the checkbox & got true & false)
    false


    i only wish to get a false when i untick the checkbox.

    PS. Solved the problem. Thanks for reading
    Last edited by GUIJAVA; 02-09-2010 at 12:22 PM. Reason: Solved

Similar Threads

  1. How can I add JCheckBox to each row?
    By batya in forum AWT / Swing
    Replies: 1
    Last Post: 11-04-2009, 09:25 PM
  2. Not able to display icon with JCheckBox
    By anindde in forum AWT / Swing
    Replies: 2
    Last Post: 11-01-2009, 03:19 AM
  3. JCheckbox in Jtree
    By shajuantony in forum AWT / Swing
    Replies: 10
    Last Post: 09-09-2009, 10:42 AM
  4. Can we add JCheckBox array into JTextArea?
    By nancyhung in forum AWT / Swing
    Replies: 1
    Last Post: 02-17-2008, 12:07 AM
  5. jcheckbox issues need help. thanks.
    By carlos123 in forum New To Java
    Replies: 3
    Last Post: 11-05-2007, 10:37 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
  •