質問

I have a case where I have to add figures in another figure, i.e., nested figures.

My figure which will contain other figure extends org.eclipse.draw2d.Figure.

I want to change the height of this figure when it contains more than 4 figures, so that all the nested figures are visible at once.

So, in the paintFigure(Graphics graphics) method, I do this:

Rectangle r = getBounds();
if( getChildren().size() > 4 ) {
        setBounds(new Rectangle(r.x, r.y, r.width, r.height + getChildren().size()-4)*10));
}

But this doesn't change the height. Well it does change it, for the time being, but when it is called again the next time, it again has the previous height, not the updated one.

Hence, visually the figure height doesn't change at all.

Any ideas on what am I doing wrong?

Or to do this in a different and/or better way?

役に立ちましたか?

解決

I was updating the height in the paintFigure(), it was changing to previous height because it was taking values from the model. I changed the height in the model, and it worked fine.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top