1 package rero.gui.background; 2 3 import javax.swing.*; 4 import java.awt.*; 5 6 import rero.config.*; 7 8 import rero.gui.background.*; 9 import java.io.*; 10 11 public class BackgroundPanel extends JPanel implements ClientStateListener 12 { 13 protected static BackgroundProperties bgProperties; 14 15 public BackgroundPanel() 16 { 17 if (bgProperties == null) 18 { 19 bgProperties = new BackgroundProperties("window", Color.black, BackgroundUtil.BG_SOLID); 20 } 21 22 ClientState.getClientState().addClientStateListener("window", this); } 24 25 public void propertyChanged(String property, String parms) 26 { 27 repaint(); 28 } 29 30 public void paint(Graphics g) 31 { 32 int x, y, width, height; 33 34 x = g.getClipBounds().x; 35 y = g.getClipBounds().y; 36 width = g.getClipBounds().width; 37 height = g.getClipBounds().height; 38 39 switch (bgProperties.getType()) 40 { 41 case BackgroundUtil.BG_DEFAULT: 42 case BackgroundUtil.BG_SOLID: 43 g.setColor(bgProperties.getColor()); 44 g.fillRect(x, y, width, height); 45 paintChildren(g); 46 break; 47 case BackgroundUtil.BG_IMAGE: 48 BackgroundUtil.drawBackground(this, g, bgProperties); 49 paintChildren(g); 50 break; 51 } 52 } 53 } 54 | Popular Tags |