Pages

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

Sunday, August 07, 2005

Customize BorderLayout of Draw2D


If you customized BorderLayout.java ,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 BorderLayout.java to CustomBorderLayout.java

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(!stretchCenterHeight){
if (childSize.height <>
area.y += (area.height - childSize.height) / 2;
area.height = childSize.height;
}
}

if(!stretchCenterWidth){
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);
layout.setStretchCenterHeight(true);


FullCode
http://cvs.sourceforge.jp/cgi-bin/viewcvs.cgi/akjrcp/draw2dexample/src/example/draw2d/CustomBorderLayoutTest.java?rev=1.1&content-type=text/vnd.viewcvs-markup

4 comments:

Anonymous said...

Hello! 

Not sure if this is the right place to post this, but here is the story of my dog called Shandy.
He was my favourite pet and he was very lively, lots of fun and very obedient. His main
passion in life was to be taken for a long walk, culminating with a big run out in his favourite
park. I would try to take him on this walk everyday, weather permitting. The park itself
was about three miles away from our house. What do you think?

By the way, I love that too!  Where did you get that at?  

See you soon! WonderGirl 




how I make money with paid surveys

Anonymous said...

The best cars
dollar rent a car
car crash
auto insurance company
used car san diego
car price
avis car rental
new car
car auction

Android app development said...

This is one of the genius and flexible post.I like your blog creativity.
Android app developers

Android developer said...

I absolutely enjoyed reading and hope you keep updating it frequently! I absolutely liked the abstraction you accept aloft here. It is actual accessible and advantageous one.

Android developer