Change shape of middle handles

I create a ‘lane’ object using JGoSubGraph. It is resizable. I want to show only TopMiddle handle and BottomMiddle handle, so that only lane’s height is resizable. I also want to make the handles nearly as wide as the lane itself, so that the user could resize it anywhere along its length. How to get this behavior? thanks,

Just override JGoObject.gainedSelection with a variation of what JGoSubGraph does:
protected void gainedSelection(JGoSelection selection) {
if (!isResizable() || !isExpanded()) {
Rectangle rect = computeBorder();
int x1 = rect.x;
int x2 = rect.x + (rect.width/2);
int x3 = rect.x + rect.width;
int y1 = rect.y;
int y2 = rect.y + (rect.height/2);
int y3 = rect.y + rect.height;
JGoHandle goh = selection.createResizeHandle(this, x1,y1, TopMiddle, true);
goh = selection.createResizeHandle(this, x1,y3, BottomMiddle, true);
Note that the resize handles will let the user change the margins. It does not change the result of JGoSubGraph.computeInsideMargins, which is the region that is inside the margins.

that works! thanks for the quick response.

The middle handles work well, but the TopLeft, TopRight, BottomLeft, BottomRight still show. How can I hide them?

??? But gainedSelection doesn’t call the base method, assuming your subgraph is resizable. You’ll need to set a break point in createResizeHandle and figure out why it’s being called outside of your override of JGoObject.gainedSelection.

my mistake, it is fixed now. thanks