|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.darwinsys.swingui.layout.RelativeLayout
public class RelativeLayout
RelativeLayout, a Relative Layout Manager for Java J2SE. Mainly for porting tired old code that uses x,y locations. You really can't just assign x,y locations to components in Java Java J2SE - it breaks badly when the user resizes (and you can not mandate that the user can't resize you -- see any book on UI design for that little discussion -- and can also look bad due to resolution independance. Symantec Cafe 1.x, for example, used to spit out unfortunate (and unmaintainable) code like this:
setLayout(null); setSize(331,241); label1=new Label("Info Applet", Label.CENTER); add(label1); label1.setBounds(91,19,107,15);
Bleaarrgghh!!! To make it work properly at all resolutions and survive user-initiated resize actions, change it to
setLayout(new RelativeLayout(331,241,false); label1=new Label("Info Applet", Label.CENTER); add("91,19", label1);Note that it's actually less work to get it right. Symantec, Microsoft, and others, please take note!
Field Summary | |
---|---|
protected java.util.List<com.darwinsys.swingui.layout.RelativeLayout.Tracker> |
curComps
to track Components added by named add form. |
protected int |
curHgt
actual size height when laid out |
protected int |
curWid
actual size width when laid out |
protected int |
reqHgt
requested absolute height of canvas |
protected int |
reqWid
requested absolute width of canvas |
Constructor Summary | |
---|---|
RelativeLayout(int wid,
int ht)
Constructs an RelativeLayout, given original hard-coded size of panel. |
Method Summary | |
---|---|
void |
addLayoutComponent(java.awt.Component comp,
java.lang.Object constraint)
This version is here in preparation for implementing LayoutManager2 |
void |
addLayoutComponent(java.lang.String name,
java.awt.Component comp)
Called by AWT when the user uses the form add(name, Component). |
void |
layoutContainer(java.awt.Container target)
Called by AWT to lay out the components in the target Container at its current size. |
java.awt.Dimension |
minimumLayoutSize(java.awt.Container target)
Called from AWT to calculate the minimum size dimensions for the target panel given the components in it. |
java.awt.Dimension |
preferredLayoutSize(java.awt.Container target)
Called by AWT to compute the preferred size for the target panel given our list of the components that it contains. |
void |
removeLayoutComponent(java.awt.Component c)
Called by AWT to remove a given component from the layout. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected int reqWid
protected int reqHgt
protected int curWid
protected int curHgt
protected java.util.List<com.darwinsys.swingui.layout.RelativeLayout.Tracker> curComps
Constructor Detail |
---|
public RelativeLayout(int wid, int ht)
Method Detail |
---|
public void addLayoutComponent(java.lang.String name, java.awt.Component comp)
addLayoutComponent
in interface java.awt.LayoutManager
name
- String with location for component c
Note: the "name" must contain x, y location, ie.,
comp
- Component to be added.public void addLayoutComponent(java.awt.Component comp, java.lang.Object constraint)
public void layoutContainer(java.awt.Container target)
layoutContainer
in interface java.awt.LayoutManager
target
- Container whose components are to be laid out.public java.awt.Dimension minimumLayoutSize(java.awt.Container target)
minimumLayoutSize
in interface java.awt.LayoutManager
target
- Container to calculate forpublic java.awt.Dimension preferredLayoutSize(java.awt.Container target)
preferredLayoutSize
in interface java.awt.LayoutManager
target
- Container to calculate forpublic void removeLayoutComponent(java.awt.Component c)
removeLayoutComponent
in interface java.awt.LayoutManager
c
- Component to be removed
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |