Back to index

wims  3.65+svn20090927
SimplePanel.java
Go to the documentation of this file.
00001 package rene.gui;
00002 
00003 import java.awt.Component;
00004 import java.awt.Dimension;
00005 
00011 public class SimplePanel extends MyPanel
00012 {      Component C1,C2;
00013        double W;
00014        int IX=0,IY=0;
00015        public SimplePanel (Component c1, double w1, Component c2, double w2)
00016        {      C1=c1; C2=c2; W=w1/(w1+w2);
00017               add(C1);
00018               add(C2);
00019        }
00020        public void doLayout ()
00021        {      int w=(int)(getSize().width*W-3*IX);
00022               C1.setSize(w,getSize().height-2*IY);
00023               C1.setLocation(IX,IY);
00024               C2.setSize(getSize().width-3*IX-w,getSize().height-2*IX);
00025               C2.setLocation(w+2*IX,IY);
00026               C1.doLayout();
00027               C2.doLayout();
00028        }
00029        public Dimension getPreferredSize ()
00030        {      Dimension d1=C1.getPreferredSize(),d2=C2.getPreferredSize();
00031               return new Dimension(d1.width+d2.width,
00032                      Math.max(d1.height,d2.height));
00033        }
00034        public void setInsets (int x, int y)
00035        {      IX=x; IY=y;
00036        }
00037 }