Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #15645
| From | markspace <-@.> |
|---|---|
| Newsgroups | comp.lang.java.programmer |
| Subject | Re: It doesn't see my 'if' statements |
| Date | 2012-06-26 19:47 -0700 |
| Organization | A noiseless patient Spider |
| Message-ID | <jsds81$mde$1@dont-email.me> (permalink) |
| References | <jsde9p$ebg$1@dont-email.me> <jsdefq$ek9$1@dont-email.me> <jsdin7$a5t$1@dont-email.me> |
On 6/26/2012 5:04 PM, bilsch wrote:
> On 6/26/2012 3:52 PM, markspace wrote:
>> On 6/26/2012 3:49 PM, bilsch wrote:
>>
>>> public void actionPerformed(ActionEvent event){
>>> String btn = event.getActionCommand();
>>> // opflag clears display
>>> if (opFlag = true){
>>
>>
>> This is assignment, not == test. You need two == for equals testing.
>>
>> If you are using NetBeans, it should have flagged this with a warning.
>> Mine does.
>>
> Thanks. My stupid mistake. NetBeans doesn't flag it on my system - ???
>
> I have now fixed those errors and it STILL doesn't work.
If the NetBeans debugger doesn't work for you, try print statements
instead. Print out the values of variables as you change them or before
testing them, to ensure the values are what you think they are.
> public void actionPerformed(ActionEvent event){
> String btn = event.getActionCommand();
> // opflag clears display
System.out.println( "opFlag="+opFlag );
> if (opFlag = true){
> gui.number1.setText(noChar);
> opFlag = false;
> }
....
> if (btn == "+") {
> addFlag = true;
> opFlag = true;
System.out.println( "addFlag and opFlag = true" );
> operand1=Double.parseDouble(strng1);}
Now you can "see" what opFlag is at the beginning of each invocation of
actionPerformed(). BTW this style of adding print statements is a very
venerable but also a very efficient way of debugging code. It would be
even better to use the logger, but one complication at a time.
Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
It doesn't see my 'if' statements bilsch <bilsch01@gmail.com> - 2012-06-26 15:49 -0700
Re: It doesn't see my 'if' statements markspace <-@.> - 2012-06-26 15:52 -0700
Re: It doesn't see my 'if' statements Lew <lewbloch@gmail.com> - 2012-06-26 16:40 -0700
Re: It doesn't see my 'if' statements bilsch <bilsch01@gmail.com> - 2012-06-26 17:22 -0700
Re: It doesn't see my 'if' statements Mike Winter <usenet@michael-winter.me.invalid> - 2012-06-27 02:04 +0100
Re: It doesn't see my 'if' statements Martin Gregorie <martin@address-in-sig.invalid> - 2012-06-26 23:44 +0000
Re: It doesn't see my 'if' statements bilsch <bilsch01@gmail.com> - 2012-06-26 17:18 -0700
Re: It doesn't see my 'if' statements bilsch <bilsch01@gmail.com> - 2012-06-26 17:04 -0700
Re: It doesn't see my 'if' statements markspace <-@.> - 2012-06-26 19:47 -0700
Re: It doesn't see my 'if' statements Roedy Green <see_website@mindprod.com.invalid> - 2012-06-27 03:16 -0700
csiph-web