Дипломная работа: Использование платформы j2me для мобильных телефонов при организации видеонаблюдений
y += d.getHeight() + currentStyle.getMargin (Component.BOTTOM);
}
}
/**
* Returns the container preferred size
*
* @param parent the parent container
* @return the container preferred size
*/
public Dimension getPreferredSize (Container parent) {
int components = parent.getComponentCount();
Style parentStyle = parent.getStyle();
int height = parentStyle.getMargin (Component.TOP)
+ parentStyle.getMargin (Component.BOTTOM);
int marginX = parentStyle.getMargin (Component.RIGHT)
+ parentStyle.getMargin (Component.LEFT);
int width = marginX;
for (int iter = 0; iter < components; iter++) {
Component current = parent.getComponentAt(iter);
Dimension d = current.getPreferredSize();
Style currentStyle = current.getStyle();
width = Math.max (d.getWidth() + marginX
+ currentStyle.getMargin (Component.RIGHT) +
currentStyle.getMargin (Component.LEFT), width);
height += currentStyle.getMargin (Component.TOP) + d.getHeight() +
currentStyle.getMargin (Component.BOTTOM);
}
Dimension size = new Dimension (width, height);
return size;