Article View: borland.public.jbuilder.java.swing
Article #10771Re: JTabbedPane and JComboBox troubles
From: Herman Quirmbach
Date: Tue, 10 Aug 1999 00:00
Date: Tue, 10 Aug 1999 00:00
41 lines
2378 bytes
2378 bytes
An example program called SwingStart in chapter 12 of Jaworski's _Java
2 Platform Unleashed_ book (SAMS) exhibits a similar bug. The problem
apparently is that the SwingStart class extends Frame, not JFrame (line
7, p.321). If you fix that and also replace line 58, p.322
add("Center", tabbedPane);
with
getContentPane().add("Center", tabbedPane);
then the program runs as it should. The book states (p.324),
"SwingStart uses the Frame class to show how Swing and AWT components
can be used interchangeably." I leave it to your imagination what three
hours later I scribbled in the margin next to that! (Note that the
SwingStart constructor declaration that should appear on line 36 is
omitted in the printed book but is on the CD.)
The interesting thing I discovered is that in running the original
code, with Frame, the following odd behavior appeared. If you click a
different tab on the tabbed pane, the new panel does not appear, as
described above. However, if you then resize the application's window,
then when the application repaints it shows the new panel after all.
I'm a beginner and have no clue what causes that, but I would be curious
if anyone would care to offer an explanation.
Thanks. HQ
Musa S Marasi wrote:
>
> Please make sure that your Frame extends JFrame and not DecorateFrame. JFrame
> is a swing component whereas DecoratedFrame is an AWT component and henceforth
> does not support multi panel arrangements.
>
> Good luck.
>
> Musa S. Marashi
>
> Horst Beham wrote:
>
> > I have the same problem as Musa S Marais in his posting from 14-Jul-99.
> > No matter which tab the user selects (even in the JBuilder2 designer), the
> > contents of the first tab is shown.
Technical Details
Message-ID:
<37AFC48C.A33BEB1C@ames.net>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<7nk1me$4ph10@forums.borland.com> <379DD138.1DB0D47@codetech.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 111d45,8a61fa9648918eb7 X-Google-Attributes: gid111d45,public From: Herman Quirmbach <hcqbach@ames.net> Subject: Re: JTabbedPane and JComboBox troubles Date: 1999/08/10 Message-ID: <37AFC48C.A33BEB1C@ames.net> X-Deja-AN: 510947866 Content-Transfer-Encoding: 7bit References: <7nk1me$4ph10@forums.borland.com> <379DD138.1DB0D47@codetech.com> X-Accept-Language: en Content-Type: text/plain; charset=us-ascii Organization: Another Netscape Collabra Server User Mime-Version: 1.0 Newsgroups: borland.public.jbuilder.java.swing