Back to index

wims  3.65+svn20090927
Panel3D.java
Go to the documentation of this file.
00001 package rene.gui;
00002 
00003 import java.awt.Color;
00004 import java.awt.Component;
00005 import java.awt.Container;
00006 import java.awt.Dimension;
00007 import java.awt.Graphics;
00008 import java.awt.LayoutManager;
00009 import java.awt.Panel;
00010 
00015 public class Panel3D extends Panel
00016        implements LayoutManager
00017 {      Component C;
00022        public Panel3D (Component c)
00023        {      C=c;
00024               setLayout(this);
00025               add(C);
00026               setBackground(C.getBackground());
00027        }
00028        
00029        public Panel3D (Component c, Color background)
00030        {      C=c;
00031               setLayout(this);
00032               add(C);
00033               setBackground(background);
00034        }
00035        
00036        public void paint (Graphics g)
00037        {      g.setColor(getBackground());
00038               if (getSize().width>0 && getSize().height>0)
00039                      g.fill3DRect(0,0,getSize().width,getSize().height,true);
00040               // C.repaint(); // probably not necessary, but Mac OSX bug ?!?
00041        }
00042 
00043        public void addLayoutComponent (String arg0, Component arg1) 
00044        {      C=arg1;
00045        }
00046        
00047        public void removeLayoutComponent(Component arg0) 
00048        {      C=null;
00049        }
00050        
00051        public Dimension preferredLayoutSize(Container arg0) 
00052        {      if (C!=null) return new Dimension(
00053                      C.getPreferredSize().width+10,C.getPreferredSize().height+10);
00054               return new Dimension(10,10);
00055        }
00056        
00057        public Dimension minimumLayoutSize(Container arg0) 
00058        {      if (C!=null) return new Dimension(
00059                      C.getMinimumSize().width+10,C.getMinimumSize().height+10);
00060               return new Dimension(10,10);
00061        }
00062        
00063        public void layoutContainer(Container arg0) 
00064        {      if (C==null) return;
00065               C.setLocation(5,5);
00066               C.setSize(getSize().width-10,getSize().height-10);
00067        }
00068 }