0

I have a check button and I was wondering how to get the value from it. When I use this code it gives me that it is selected always, even when it is not.

public void itemStateChanged(ItemEvent e) {
		// TODO Auto-generated method stub
		JCheckBox sourceBox = ((JCheckBox)e.getSource());
		wave1Invert = wave1Inv.get ();
		wave2Invert = wave2Inv.isSelected ();
		if (wave1Inv == sourceBox){
			
			if (wave1Invert = true){
				System.out.println ("Wave 1 Inv");
			}
			else if (wave1Invert = false){
				System.out.println ("Wave 1 NOT Inv");
			}
		}
			
		if (wave2Inv == sourceBox){
			if (wave2Invert = true){
				System.out.println ("Wave 2 Inv");
			}
			else if (wave2Invert = false){
				System.out.println ("Wave 2 NOT Inv");
			}
		}
	}

Thanks for your help

2
Contributors
2
Replies
3
Views
6 Years
Discussion Span
Last Post by sirlink99
0

Thanks that fixed the problem. Though I thought that to compare booleans you just use =, but I guess I was wrong.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.