mgarin / weblaf

WebLaF is a fully open-source Look & Feel and component library written in pure Java for cross-platform desktop Swing applications.
http://weblookandfeel.com
GNU General Public License v3.0
1.13k stars 234 forks source link

what's the best way to just detect changes to any boxes in a WebCheckBoxList #643

Open mokun opened 3 years ago

mokun commented 3 years ago

How do you write an action listener method to just detect changes in any boxes in a WebCheckBoxList ?

mgarin commented 3 years ago

Something like this would work right now:

final WebCheckBoxList list = new WebCheckBoxList ();
list.addListDataListener ( new ListDataAdapter ()
{
    @Override
    public void contentsChanged ( final ListDataEvent e )
    {
        final int index = e.getIndex0 ();
        final boolean selected = list.isCheckBoxSelected ( index );
    }
} );

That being said, these events can also be thrown when list data itself changes. It's not the best way to handle it, so i'll keep this issue and will add a separate check state listener in next update.