Hi !
Featured games (91)
games approved by the League of Dukes
Games in Showcase (762)
Games in Android Showcase (229)
games submitted by our members
Games in WIP (846)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  architecture: best way to implement a color palette  (Read 1704 times)
0 Members and 1 Guest are viewing this topic.
Offline skytomorrownow

Junior Devvie

« Posted 2006-08-19 19:24:42 »

i'm building the gui for my app mostly using swing components. i know that at somepoint i am going to want to tweak the coloring of the interface. so instead of hardcoding the colors into each component, i've created a simple object to wrap public fields of type Color. however, this means that i have to create this aforementioned ColorPalette object to access it from within my gui components.

in action, it might look like this:

ColorPalette cp = new ColorPalette();
... (somewhere later in the component's code) ...
this.setBackground( cp.bkgd );

obviously this will save time later if i want to tweak colors, or even give the user control over some things. however, it seems kind of clunky. i had a suspicion that some java guru might have a slicker way to approach global setttings.

if i make the ColorPalette a final class, will that mean i don't have to instantiate it each time?

any ideas approaches to this kind of a typical problem would be great.

Offline Ask_Hjorth_Larsen

Junior Devvie

Java games rock!

« Reply #1 - Posted 2006-08-20 01:34:32 »

It is possible to design your own look-and-feel. I have not done this, but I believe it would be the proper way to solve the problem in general.  There's some interesting stuff at which allows you to globally control the appearance of components. Or perhaps you can do something with the Substance look-and-feel which someone mentioned in another thread (Commander Keith?).
Offline oNyx

JGO Coder

Medals: 2

pixels! :x

« Reply #2 - Posted 2006-08-20 03:42:11 »

Look and feels usually use some kind of theme which can be overridden. Take a look at... lets see...


There you can see a property based theme, which supports the 3 primary/secondary colors and "black"/"white".

You can also use UIManager.put for overriding specific things. Here is some list with the default values:

You use it like:
UIManager.put("ScrollBar.background", new ColorUIResource(255,255,255));

UIManager.put("ToolTip.border", BorderFactory.createEmptyBorder());

弾幕 ☆ @mahonnaiseblog
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline skytomorrownow

Junior Devvie

« Reply #3 - Posted 2006-08-20 04:53:09 »

hey great information. however, i'm definitely creating some custom UI elements such as a time ruler. however, it's mostly made from components. i have attached the image of the interface. it's purposely quite simple, and most of it is just various JComponents. you can see that they all share a simple color palette that i want to be able to change globally.

should i create a ColorPalette class to store my colors, then create it as a static field of a master abstract gui class? how would you design this?

any tips much appreciated.
Pages: [1]
  ignore  |  Print  

EgonOlsen (353 views)
2018-06-10 19:43:48

EgonOlsen (354 views)
2018-06-10 19:43:44

EgonOlsen (294 views)
2018-06-10 19:43:20

DesertCoockie (529 views)
2018-05-13 18:23:11

nelsongames (844 views)
2018-04-24 18:15:36

nelsongames (832 views)
2018-04-24 18:14:32

ivj94 (1264 views)
2018-03-24 14:47:39

ivj94 (396 views)
2018-03-24 14:46:31

ivj94 (1067 views)
2018-03-24 14:43:53

Solater (414 views)
2018-03-17 05:04:08
Java Gaming Resources
by philfrei
2017-12-05 19:38:37

Java Gaming Resources
by philfrei
2017-12-05 19:37:39

Java Gaming Resources
by philfrei
2017-12-05 19:36:10

Java Gaming Resources
by philfrei
2017-12-05 19:33:10

List of Learning Resources
by elect
2017-03-13 14:05:44

List of Learning Resources
by elect
2017-03-13 14:04:45

SF/X Libraries
by philfrei
2017-03-02 08:45:19

SF/X Libraries
by philfrei
2017-03-02 08:44:05 is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!