Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!eternal-september.org!feeder.eternal-september.org!mx04.eternal-september.org!.POSTED!not-for-mail From: Jeff Higgins Newsgroups: comp.lang.java.gui Subject: Re: Debugging Focus problem Date: Thu, 22 Dec 2011 17:10:14 -0500 Organization: A noiseless patient Spider Lines: 23 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Thu, 22 Dec 2011 22:05:52 +0000 (UTC) Injection-Info: mx04.eternal-september.org; posting-host="qwFw1g9RsQ6TkML5yezG9A"; logging-data="10667"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18PREdxuI9XFiXDxtK7x84OBmUhXwzz5nE=" User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.16) Gecko/20111110 Icedove/3.0.11 In-Reply-To: Cancel-Lock: sha1:p7CI7ViZC2Au1W/e+o5nbJCrQWY= Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.gui:4851 On 12/22/2011 04:54 PM, Novice wrote: > I'm having a problem putting the focus where I want it in certain cases in > a class I am revising. In most circumstances, the focus is where the > program is telling it to be but I'm having one annoying situation where it > isn't, specifically when I first display the GUI. > > The last statement I execute before setting the JFrame visible is: > myTextArea.requestFocus(); > > However, the focus doesn't appear to be on ANY control of my GUI when it > comes up. This impression was reinforced when I added this line after > trying to set the focus on myTextArea: > System.out.println("The focus is currently on: " + getFocusOwner()); > > That statement indicated that the focus was on null. > > Why would my requestFocus() be ignored - or honored but then immediately > removed? - when first displaying the GUI but work perfectly after any other > event? In each case, I set the focus on the exact same JTextArea. > > I'm using Java 1.6.18 in Eclipse 3.7. >