Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.glorb.com!npeer01.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!border3.nntp.dca.giganews.com!Xl.tags.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!local2.nntp.dca.giganews.com!nntp.earthlink.com!news.earthlink.com.POSTED!not-for-mail NNTP-Posting-Date: Fri, 29 Jun 2012 10:12:32 -0500 Date: Fri, 29 Jun 2012 08:12:24 -0700 From: Patricia Shanahan User-Agent: Mozilla/5.0 (Windows NT 5.2; WOW64; rv:13.0) Gecko/20120614 Thunderbird/13.0.1 MIME-Version: 1.0 Newsgroups: comp.lang.java.programmer Subject: Re: I need a different approach - suggestions please References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Message-ID: Lines: 36 X-Usenet-Provider: http://www.giganews.com NNTP-Posting-Host: 70.230.202.8 X-Trace: sv3-9QUbim4ujhwljc6eTccCbv96FrPBT/2L2p9kV83zKovpipl7rHY8h04qY0+606FKJ38hydvJu+9BTMl!4zY/8fSr4nf/eGEZjW3m8nKbtKlbkzblkJ8LoXsxTab4q+WdX3XWY/EXxX4gkt1QXwiMSociq0Ae!k43ZHQQqC/mJPcm01edEKBZJcIQE/MRmi3yL4Rw2vMKF X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.3.40 X-Original-Bytes: 3013 X-Received-Bytes: 3154 Xref: csiph.com comp.lang.java.programmer:15748 On 6/25/2012 3:31 PM, bilsch wrote: > I'm trying to make a program that works like the calculator in Windows > Accessories - all input is from button clicks. Below I listed a > stripped down version of the GUI and a little of the processing behind > it. It is in two small files. I had intended that the program would > display a sequence of digits from button clicks, which I would then > convert into a Double precision number. The problem is I am constrained > to initialize the string within the method that accumulates the sequence > of digits. Everytime the method is called the string is reinitialized > with the result that my sequence of digits is only ever one digit long. > My plan would work if I could initialize the string outside the method, > however variable scope in Java doesn't allow it. ... I'm going back to the base article, to suggest a basically different approach. During my spare time over the last couple of weeks I've been studying an unfamiliar C++ graphics library. I realized that my normal approach to learning languages and libraries was entirely different from yours. I wrote a series of very simple, small programs, each of which introduced only one new technique. For example, my program for learning to connect a button to the code that should run when it is clicked created a window containing one button, and wrote "hello" to standard out each time it was clicked. When that was working I advanced to two buttons doing different things. Each learning program incorporated at most one new technique. The programs I was really trying to write did not use any new graphics techniques - I had tried everything out in smaller programs. Have you considered a step-by-step approach, as an alternative to writing an application and then trying to make it work? Patricia