Here you can find the source of onCheckBoxChange(JCheckBox field, final Runnable task)
public static void onCheckBoxChange(JCheckBox field, final Runnable task)
//package com.java2s; /**// w w w . ja v a 2 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 */ 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(); } }); } }