🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.swing
Article #1020

Re: CardLayout

#1020
From: Alex Stylianos
Date: Tue, 14 Sep 2004 06:54
51 lines
2652 bytes
"Alex Stylianos" <alex@dreamedge.com> wrote in message 
news:41468990@newsgroups.borland.com...
> Hi all
>
> I suppose this must be a common problem but I cannot find a good solution:
>
> I am using JDK 1.4.2_01-b06 and the problem is that I cannot have a 
> CardLayout switch cards properly.
> There are no errors reported by JBuilder but the CardLayout does not 
> update as it should. I have tried switching panels with the following 3 
> different ways:
>
> 1) ((CardLayout)pnMain.getLayout()).show(pnMain, pn);  // where pn is the 
> name of the new panel
>
> 2) explicitly hidding all cards and showing the one that should be in 
> front
>
> 3) starting a JTimer with an interval of 3 seconds (3000 msec) in order to 
> avoid the collision of multiple repaint() calls
>
> nothing seems to work as it should
>
> is this a known problem? or what am I missing??
>
> TIA
> Alex
>

perhaps I should add that I have created my own version of JPanel because I 
want to have background images so I needed to override the paint() method.. 
the code for paint() is here (although I don't think it makes any difference 
for the problem):

  public void paint(Graphics g) {
    if (tracker != null && image != null) {
      if ((tracker.statusAll(false) & MediaTracker.ERRORED) != 0) { }
      else if (tracker.statusID(imageID, true) == MediaTracker.COMPLETE) {
        int x = 0, y = 0;
        while (y < getSize().height) {
          x = 0;
          while (x < getSize().width) {
            g.drawImage(image, x, y, this);
            x += image.getWidth(null);
          }
          y += image.getHeight(null);
        }
      }
    }
    super.paint(g);
  }
Technical Details
Message-ID: <4146958a@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-mail
References: <41468990@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 111d45,5ea5dd499f3c6a16
X-Google-Attributes: gid111d45,public
X-Google-Language: ENGLISH,ASCII-7-bit
Reply-To: "Alex Stylianos" <alex@dreamedge.com>
From: "Alex Stylianos" <alex@dreamedge.com>
Newsgroups: borland.public.jbuilder.java.swing
References: <41468990@newsgroups.borland.com>
Subject: Re: CardLayout
Date: Tue, 14 Sep 2004 09:54:02 +0300
Lines: 54
Organization: none
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.2180
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180
X-RFC2646: Format=Flowed; Response
NNTP-Posting-Host: 212.54.223.217
Message-ID: <4146958a@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1095144842 212.54.223.217 (13 Sep 2004 23:54:02 -0700)
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