There is a form:

enter image description here

Next, the context menu of the “AND” button is called (for each button), then Events – Action – ActionPerformed selected Events – Action – ActionPerformed enter image description here

Why fields are underlined?

    1 answer 1

    In this scope, the b1 and b2 fields do not exist.

    Make them global, that is, declare inside a class, not methods. However, inside the methods you can switch field values ​​depending on the state of the switches on the form.

     class Class { boolean b1 = false, b2 = false; } 

    Personal recommendation: make associative, mnemonic names.