Path: csiph.com!usenet.pasdenom.info!news.albasani.net!eternal-september.org!feeder.eternal-september.org!mx04.eternal-september.org!.POSTED!not-for-mail From: markspace <-@.> Newsgroups: comp.lang.java.programmer Subject: Re: It doesn't see my 'if' statements Date: Tue, 26 Jun 2012 19:47:26 -0700 Organization: A noiseless patient Spider Lines: 51 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Wed, 27 Jun 2012 02:47:29 +0000 (UTC) Injection-Info: mx04.eternal-september.org; posting-host="IZQsHU8CwMUPnWgvh4wwWA"; logging-data="22958"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+GwFZ8f+hVgUGvPodgCfA0Cox0gqDjGyI=" User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:13.0) Gecko/20120614 Thunderbird/13.0.1 In-Reply-To: Cancel-Lock: sha1:IGmQhm3JZM9THRoXlDth4iISIhc= Xref: csiph.com comp.lang.java.programmer:15645 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.