JCheckBox on Check Box Change - Java Swing

Java examples for Swing:JCheckBox

Description

JCheckBox on Check Box Change

Demo Code

/**/*from w ww .  j a  va2  s  . c  o m*/
 * Copyright (C) 2010-14 pvmanager developers. See COPYRIGHT.TXT
 * All rights reserved. Use is subject to license terms. See LICENSE.TXT
 */
//package com.java2s;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JCheckBox;

public class Main {
    public static void onCheckBoxChange(JCheckBox field, final Runnable task) {
        field.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                task.run();
            }
        });
    }
}

Related Tutorials