Drawing Selection Box

Hello, I’m fairly new the JGo API and have only been using it for about a month and still getting used to it.

Right now I’m trying to draw a selection box and have it stay visible when the user releases the mouse button. I’m having a hard time trying to figure out where to start. I have added a ViewListener to the JGoView object and can grab the event when objects are selected but I’m not sure where to go from there…

Plus, is it possible to only grab certain objects in a particular layer?

Thanks for any help!

I'm not sure what you want this "selection box" to be able to do, if anything. I think you don't care about any selection events. Instead, I suggest overriding the JGoView.selectInBox method. Besides calling the super method in order to actually select the objects inside the argument rectangle, you can add a JGoRectangle whose BoundingRect is that rectangle, to the JGoView. I would keep a single such JGoRectangle in the view, and make it Visible and change its BoundingRect each time selectInBox is called. I'm not sure when you would make this JGoRectangle be not Visible. There are a bunch of policy choices you could make.
For your second question, you can call JGoObject.setSelectable(false) to prevent the user from selecting/dragging/copying/deleting/resizing.

Sorry for not better explaining what I want the selection box to do.

Right now in the current application there is a toggle to display JGoImages that will be drawn on top of other JGoObjects via a JGoLayer. What we want our users to be able to do is to draw a selection box over these images which will then filter out only those images within the box and set the others invisible.

Reason I want the box to remain visible is only for a visual cue to the user. I notice in the current application that I’m working on that once the selection is drawn, the bounding box disappears.

Maybe that clears things up some about what I wanted it to do.

OK, then it sounds like what I suggested should work for you.