Article View: borland.public.jbuilder.java.swing
Article #886Re: Questionable JTabbedPane
From: Paul Furbacher [TeamB]
Date: Tue, 02 Nov 2004 16:55
Date: Tue, 02 Nov 2004 16:55
96 lines
3749 bytes
3749 bytes
user@domain.invalid wrote:
> Hi everyone, will you please spend some time with my problem and give
> some clue to the solution to me? I am going to include 1)program
> description, and 2)java source file below (instead of 'attaching' them).
> I described my problem or, I believe, JTabbedPane's problem in 1).
>
> Your hint, clue, suggestion, or even question is greatly appreciated.
>
> PS I tested my program in JBuilderX (Foundation), NetScape7, and MSIE7
> and the behavior of my program is the same.
> [... lots of verbiage omitted ...]
First, you don't have to run your code as
an applet to see this. Just create
a JFrame, add the tabbed panel, and do
your stuff.
Second, it's highly unlikely that you would
draw a string into a text pane. How it is
being drawn is probably complex enough to
cause this phenomenon. I'd draw into
a panel, not a text pane, which you add
to the tabbed pane. Change
your code to add a JPanel which has
a BorderLayout. Then add the textpane to
the JPanel: add it using a BorderLayout.EAST.
Set the preferred size of the textpane
to something like 100, 190.
if ( tbp.getTabCount() == 0 ) {
JPanel p = new JPanel(new BorderLayout());
p.add(txp, BorderLayout.EAST);
txp.setPreferredSize(new Dimension(100, 190));
tbp.addTab("tab 1", p);
}
Third, change the draw string method so that it draws into
the *panel*, not the textpane.
tbp.getSelectedComponent().getGraphics();
...
Fourth, put the contents of the draw string method
into a nested class which implements Runnable
and call an instance of that runnable
using
...
if ( useDrw ) {
SwingUtilities.invokeLater(
new UpdateRunner(n, msg2));
}
...
public class UpdateRunner implements Runnable {
int n;
String msg;
UpdateRunner(int number, String message) {
n = number;
msg = message;
}
public void run() {
// put the contents of your drawStringWay()
// method here.
}
}
It may be an interesting phenomenon, but
the important question is: how does this
affect you in the real world.
Finally, we do all of our replying in
public -- that is, we don't reply to
requests for responses to a questioner's
email address. Please visit the newsgroup
guidelines Web page to check on this and
other matters.
--
Paul Furbacher (TeamB)
Save time, search the archives:
http://www.borland.com/newsgroups/ngsearch.html
Is it in Joi Ellis's Faq-O-Matic?
http://www.visi.com/~gyles19/fom-serve/cache/1.html
Finally, please send responses to the newsgroup only.
That means, do not send email directly to me.
Thank you.
Technical Details
Message-ID:
<4187bc15$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!fu-berlin.de!newsfeed.iinet.net.au!newsfeed.iinet.net.au!PeerFeed.KWeb.on.ca!news.kweb.on.ca!newsgroups.borland.com!not-for-mailReferences:
<41871c3a@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 111d45,662c888bffac8e46 X-Google-Attributes: gid111d45,public X-Google-Language: ENGLISH,ASCII-7-bit Date: Tue, 02 Nov 2004 11:55:49 -0500 From: "Paul Furbacher [TeamB]" <pfurbacher@mac.com> Organization: Reverse Alchemy, Inc. User-Agent: Mozilla Thunderbird 0.8 (Macintosh/20040913) X-Accept-Language: en-us, en MIME-Version: 1.0 Newsgroups: borland.public.jbuilder.java.swing Subject: Re: Questionable JTabbedPane References: <41871c3a@newsgroups.borland.com> In-Reply-To: <41871c3a@newsgroups.borland.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit NNTP-Posting-Host: 69.142.222.65 Message-ID: <4187bc15$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1099414549 69.142.222.65 (2 Nov 2004 08:55:49 -0700) Lines: 96 Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!fu-berlin.de!newsfeed.iinet.net.au!newsfeed.iinet.net.au!PeerFeed.KWeb.on.ca!news.kweb.on.ca!newsgroups.borland.com!not-for-mail