🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: Windows Look & Feel for applet?

#1824
From: Gillmer J. Derge [TeamB]
Date: Sun, 03 Aug 2003 21:04
33 lines
2492 bytes
"Ramon F Herrera" <ramon@jonjay.com> wrote in message
news:3F2D40FE.4030403@jonjay.com...
> Having said that, I still have the same problem (I always get
> the metal L&F no matter what my code says).  Since a lot of
> my applet's code is placed there by JBuilder, what I need to
> know now is where (in what method) should I set the L&F?

I'm assuming that your class looks like it would if you use JBuilder's
designer to create it.  That is, something like this:

    public class MyApplet extends Applet {
      JLabel label = new JLabel();
      public MyApplet() { /* ... */ }
      public void init() { /* ... */ }
      public void start() { /* ... */ }
      public void stop() { /* ... */ }
      public void destroy() { /* ... */ }
    }

The key point is the way the label (or whatever components your applet
uses) is initialized.  The label is created when the applet is
constructed, before any of the life cycle methods are invoked.  So if
you then set the look and feel in the init method, for example, the
label has already been built with the metal look and feel.

One solution is to call SwingUtilities.updateComponentTree at the end of
your init method, after setting the look and feel and performing all
other initialization steps.

    SwingUtilities.updateComponentTreeUI(this);

-- 
Gillmer J. Derge [TeamB]
Technical Details
Message-ID: <3f2d78eb@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-04!sn-xit-01!sn-xit-09!supernews.com!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <3F2BF51B.2020307@jonjay.com> <3F2C0E9A.7050509@formlessvoid.com> <3F2C69A2.7080100@jonjay.com> <3f2d20c4$3@newsgroups.borland.com> <3F2D40FE.4030403@jonjay.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 111d45,b0ac4314a1e5d01e
X-Google-Attributes: gid111d45,public
X-Google-ArrivalTime: 2003-08-03 14:10:34 PST
From: "Gillmer J. Derge [TeamB]" <spam@gillmerderge.com>
Newsgroups: borland.public.jbuilder.java.swing
References: <3F2BF51B.2020307@jonjay.com> <3F2C0E9A.7050509@formlessvoid.com> <3F2C69A2.7080100@jonjay.com> <3f2d20c4$3@newsgroups.borland.com> <3F2D40FE.4030403@jonjay.com>
Subject: Re: Windows Look & Feel for applet?
Date: Sun, 3 Aug 2003 17:04:45 -0400
Lines: 35
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
NNTP-Posting-Host: 65.110.133.233
Message-ID: <3f2d78eb@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1059944683 65.110.133.233 (3 Aug 2003 14:04:43 -0700)
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-04!sn-xit-01!sn-xit-09!supernews.com!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail