about my opensource eclipse java applications recently i'm studying GWT and Android

Sunday, August 07, 2005

Customize BorderLayout of Draw2D

If you customized ,you could do such things.

Certainly,If you overwrited getPreferedSize(),and you could do.
But If you did customize BorderLayout,You could control center figure of BorderLayout.
It's simple and usefull.

I copy from to

and new field.
and create both of get and set methods.
private boolean stretchCenterWidth=true;
private boolean stretchCenterHeight=false;

and ,on layout() methods,
I replace code to when stretchCenter* is true,layoutmanager stretch figure width or height.
if (childSize.height <>
area.y += (area.height - childSize.height) / 2;
area.height = childSize.height;

if (childSize.width <>
area.x += (area.width - childSize.width) / 2;
area.width = childSize.width;
finally use call in your program like this.
CustomBorderLayout layout=new CustomBorderLayout(); layout.setStretchCenterWidth(true);