🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

SV: L&F primary colors

#10130
From: Johan Forsberg
Date: Wed, 10 Nov 1999 00:00
65 lines
3010 bytes
Ronen <ronenm@netvision.net.il> skrev i
diskussionsgruppsmeddelandet:8098vf$j5511@forums.borland.com...
> Hi
> I'm using MetalLookAndFeel
> Does anyone knows how can I change the primary colors
> (ScrollBars, Selected items background, splitters, etc..)
> Thanks Ronen

Metal uses thre primary (gray) and three secondary (blue) shades.
In our applet we have setFg and setBg methods that automatically calculate
the correct
intensity levels for the three shades. That way you can change the look of
all of Metal
by setting just two colors:

class MyMetalTheme extends MetalTheme {
            static public ColorUIResource primary1 = new
ColorUIResource(102, 102, 153);
            static public ColorUIResource primary2 = new
ColorUIResource(153, 153, 204);
            static public ColorUIResource primary3 = new
ColorUIResource(204, 204, 255);
            static public ColorUIResource secondary1 = new
ColorUIResource(102, 102, 102);
            static public ColorUIResource secondary2 = new
ColorUIResource(153, 153, 153);
            static public ColorUIResource secondary3 = new
ColorUIResource(204, 204, 204);

           ... etc etc check out javax.swing.plaf.metal.MetalTheme
};
MyMetalTheme tema=new MyMetalTheme();
MetalLookAndFeel plaf = (MetalLookAndFeel)UIManager.getLookAndFeel();
plaf.setCurrentTheme(tema);

...

static void setFrameBg(Color c) {
  float hsb[]=Color.RGBtoHSB(c.getRed(), c.getGreen(), c.getBlue(), null);
  Applet1.tema.secondary1 =  new ColorUIResource(Color.HSBtoRGB(hsb[0],
hsb[1], (float)(102/255.0)));
  Applet1.tema.secondary2 =  new ColorUIResource(Color.HSBtoRGB(hsb[0],
hsb[1], (float)(153/255.0)));
  Applet1.tema.secondary3 =  new ColorUIResource(Color.HSBtoRGB(hsb[0],
hsb[1], (float)(204/255.0)));
 }
 static void setFrameFg(Color c) {
  float hsb[]=Color.RGBtoHSB(c.getRed(), c.getGreen(), c.getBlue(), null);
  Applet1.tema.primary1 =  new ColorUIResource(Color.HSBtoRGB(hsb[0],
hsb[1], (float)(102/255.0)));
  Applet1.tema.primary2 =  new ColorUIResource(Color.HSBtoRGB(hsb[0],
hsb[1], (float)(153/255.0)));
  Applet1.tema.primary3 =  new ColorUIResource(Color.HSBtoRGB(hsb[0],
hsb[1], (float)(204/255.0)));
 }

You will probably need to do a

        try{
            UIManager.setLookAndFeel(UIManager.getLookAndFeel());
        } catch( Exception ex){};
        SwingUtilities.updateComponentTreeUI(applet1);

whenever you change the theme.
Technical Details
Message-ID: <80bdhh$6sl5@forums.borland.com>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <8098vf$j5511@forums.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 111d45,8535edc2c8bfaefe
X-Google-Attributes: gid111d45,public
From: "Johan Forsberg" <jfo@SPAM_SPAM_EGGS_SPAMstmf.se>
Subject: SV: L&F primary colors
Date: 1999/11/10
Message-ID: <80bdhh$6sl5@forums.borland.com>
X-Deja-AN: 546816228
References: <8098vf$j5511@forums.borland.com>
X-Priority: 3
X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2314.1300
Organization: Another Netscape Collabra Server User
X-MSMail-Priority: Normal
Newsgroups: borland.public.jbuilder.java.swing