1 14 package org.compiere.plaf; 15 16 import java.awt.Graphics ; 17 18 import javax.swing.JComponent ; 19 import javax.swing.JPanel ; 20 import javax.swing.plaf.ComponentUI ; 21 import javax.swing.plaf.basic.BasicPanelUI ; 22 23 39 public class CompierePanelUI extends BasicPanelUI 40 { 41 46 public static ComponentUI createUI (JComponent c) 47 { 48 return s_panelUI; 50 } 52 53 private static CompierePanelUI s_panelUI = new CompierePanelUI(); 54 55 56 57 61 protected void installDefaults (JPanel p) 62 { 63 super.installDefaults(p); 64 if (s_setDefault && p.getClientProperty(CompierePLAF.BACKGROUND) == null) 65 p.putClientProperty (CompierePLAF.BACKGROUND, s_default); 66 } 68 69 70 85 public void update (Graphics g, JComponent c) 86 { 87 if (c.isOpaque()) 89 updateIt (g, c); 90 paint (g, c); } 93 98 static void updateIt (Graphics g, JComponent c) 99 { 100 104 CompiereColor bg = null; 106 try 107 { 108 bg = (CompiereColor)c.getClientProperty(CompierePLAF.BACKGROUND); 109 } 110 catch (Exception e) 111 { 112 System.err.println("CompierePanelUI - ClientProperty: " + e.getMessage()); 113 } 114 if (bg != null) 116 { 117 bg.paint (g, c); 119 } 120 else 121 { 122 g.setColor(c.getBackground()); 124 g.fillRect(0,0, c.getWidth(), c.getHeight()); 125 } 126 } 129 130 131 132 private static CompiereColor s_default = new CompiereColor(); 133 134 private static boolean s_setDefault = false; 135 136 137 141 public static void setDefaultBackground (CompiereColor bg) 142 { 143 if (bg == null) 144 return; 145 s_default.setColor(bg); 146 } 148 152 public static CompiereColor getDefaultBackground() 153 { 154 return s_default; 155 } 157 161 public static void setSetDefault (boolean setDefault) 162 { 163 s_setDefault = setDefault; 164 } 166 170 public static boolean isSetDefault() 171 { 172 return s_setDefault; 173 } 175 } | Popular Tags |