1 package aurelienribon.tweenengine.applets; 2 3 import aurelienribon.utils.swing.GroupBorder; 4 import java.awt.Color; 5 import java.awt.Component; 6 import java.awt.Container; 7 import java.awt.Font; 8 import javax.swing.JButton; 9 import javax.swing.JCheckBox; 10 import javax.swing.JComponent; 11 import javax.swing.JLabel; 12 import javax.swing.JSlider; 13 import javax.swing.border.Border; 14 15 public class Theme { 16 public static final Color MAIN_BACKGROUND = new Color(0x444444); 17 public static final Color MAIN_FOREGROUND = new Color(0xF0F0F0); 18 public static final Color MAIN_ALT_BACKGROUND = new Color(0x707070); 19 public static final Color MAIN_ALT_FOREGROUND = new Color(0xF0F0F0); 20 21 public static final Color HEADER_BACKGROUND = new Color(0x707070); 22 public static final Color HEADER_FOREGROUND = new Color(0xF0F0F0); 23 24 public static final Color TEXTAREA_BACKGROUND = new Color(0x333333); 25 public static final Color TEXTAREA_FOREGROUND = new Color(0xF0F0F0); 26 public static final Color TEXTAREA_SELECTED_BACKGROUND = new Color(0x808080); 27 public static final Color TEXTAREA_SELECTED_FOREGROUND = new Color(0xF0F0F0); 28 29 public static final Color CONSOLE_BACKGROUND = new Color(0xA5A5A5); 30 public static final Color CONSOLE_FOREGROUND = new Color(0x000000); 31 32 public static final Color SEPARATOR = new Color(0xB5B5B5); 33 apply(Component cmp)34 public static void apply(Component cmp) { 35 if (cmp instanceof JComponent) { 36 JComponent c = (JComponent) cmp; 37 Border border = c.getBorder(); 38 if (border != null && border instanceof GroupBorder) { 39 Font font = c.getFont(); 40 c.setFont(new Font(font.getFamily(), Font.BOLD, font.getSize())); 41 c.setBackground(MAIN_ALT_BACKGROUND); 42 c.setForeground(MAIN_ALT_FOREGROUND); 43 c.setOpaque(false); 44 } 45 } 46 47 if (cmp instanceof JLabel) { 48 JLabel c = (JLabel) cmp; 49 c.setForeground(MAIN_FOREGROUND); 50 } 51 52 if (cmp instanceof JCheckBox) { 53 JCheckBox c = (JCheckBox) cmp; 54 c.setForeground(MAIN_FOREGROUND); 55 c.setOpaque(false); 56 } 57 58 if (cmp instanceof Container) { 59 Container c = (Container) cmp; 60 for (Component child : c.getComponents()) 61 apply(child); 62 } 63 64 if (cmp instanceof JButton) { 65 JButton c = (JButton) cmp; 66 c.setOpaque(false); 67 } 68 69 if (cmp instanceof JSlider) { 70 JSlider c = (JSlider) cmp; 71 c.setOpaque(false); 72 c.setForeground(MAIN_FOREGROUND); 73 } 74 } 75 } 76