Article View: borland.public.jbuilder.java.swing
Article #721Re: jTabbedPane focus problem
From: John T. Dow
Date: Tue, 04 Jan 2005 20:36
Date: Tue, 04 Jan 2005 20:36
68 lines
3946 bytes
3946 bytes
Arth > It works for me. (Just tried it) What surrounding container are you using > that doesn't have a validate() method? I assume you aren't using a JApplet? > If you type this.validate() are you sure this isn't a valid method? > validate() is a method of awt.Container, which many containers such as > JFrame inherit from. 1 - this.validate() and this.getContentPane() don't work. Neither is defined. I don't know why. But, I can explicitly name the outermost panel and validate, no problem. So I've tried that as a workaround. 2 - You probably changed the tab by clicking the mouse on the tab. I've been trying to change the tab programmatically by doing setSelectedIndex(appropriatetabindex). I have found that clicking the tab made focus to go the desired text field. In fact, validate wasn't necessary. But calling setSelectedIndex does not work. After playing with it some more, I find that clicking the tab doesn't always work. Displays I've put in show that the text field gets focus, then loses it. At first it seemed that focus was going to some unknown text field (I couldn't identify it by coordinates or size). Later on the focus was going to one of my buttons (not on the tabbed pane but on an enclosing panel). These buttons that weren't supposed to get focus, so I did setFocusable(false) for all of them. Now the the focus goes to a "RepeatButton". But I have no repeatbutton in my application! Looks like a bug to me. My java is 1.4.2_01-b06 (the version on the JBuilder CD). My JBuilder is X Enterprise. My application has over 20 internal frames, and the problem tabbed pane is on one of them. It's a fairly complicated one, so I tried all of this on a much simpler internal frame and got the same results. Bottom line: calling component.requestFocus() in the stateChanged event works some but not all of the time when the tab is clicked with the mouse, but it never works when setSelectedIndex is called because the component gets focus but then loses it to la-la land. John > > I didn't need to request focus to the panel, I just called it directly on > the component that I wanted to end up with the focus, after calling > validate(). > > Perhaps you need to post a very simple example that demonstrates your > problem. You also haven't said which version of JBuilder and which JDK you > are using. Perhaps this is affecting what you are doing. > > Arth > > "John T. Dow" <john@johntdow.com> wrote in message > news:41DA069C.3060608@johntdow.com... > >>Arthur, your technique doesn't work for me, because this.getContentPage() >>and validate() aren't defined. I've been working with a state changed >>event, but I created a mouseClicked event as you have and still no go. >> > > >
Technical Details
Message-ID:
<41DAFE36.2000900@johntdow.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!proxad.net!213.200.89.82.MISMATCH!tiscali!newsfeed1.ip.tiscali.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<41D99FA3.7060700@johntdow.com> <41d9ade3@newsgroups.borland.com> <41DA069C.3060608@johntdow.com> <41da51e6$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 111d45,a0ad10712e673590 X-Google-Attributes: gid111d45,public X-Google-Language: ENGLISH,ASCII-7-bit Message-ID: <41DAFE36.2000900@johntdow.com> Date: Tue, 04 Jan 2005 15:36:06 -0500 From: "John T. Dow" <john@johntdow.com> User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.4) Gecko/20030624 Netscape/7.1 (ax) X-Accept-Language: en-us, en MIME-Version: 1.0 Newsgroups: borland.public.jbuilder.java.swing Subject: Re: jTabbedPane focus problem References: <41D99FA3.7060700@johntdow.com> <41d9ade3@newsgroups.borland.com> <41DA069C.3060608@johntdow.com> <41da51e6$1@newsgroups.borland.com> In-Reply-To: <41da51e6$1@newsgroups.borland.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit NNTP-Posting-Host: 151.201.222.38 X-Trace: newsgroups.borland.com 1104870964 151.201.222.38 (4 Jan 2005 12:36:04 -0800) Lines: 69 Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!proxad.net!213.200.89.82.MISMATCH!tiscali!newsfeed1.ip.tiscali.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail