Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Swing Editor

Status
Not open for further replies.

SSJ

Programmer
Sep 26, 2002
54
PT
I'm trying to make a basic production layout editor. I'm thinking of using swing and JPanels.

Basically I need to display JPanels inside another JPanel with XYLayout and then be able to move and resize them to change the layout. Each panel will represent a production section.

I can add the new JPanels(sections) using D&D with no problems and I can move them around to new positions with D&D also (Is this the better choice? Or is there a cleaner way of moving them?).

My main concern here is about resizing them, I have no clue on how will I be able to do it. How can I be able to select a JPanel and change it's dimensions manually like JBuilder, Eclipse or other IDEs Design editor does?
I think it has something to do with MarqueeHandlers or something, but it's really all dark here for me so any directions or examples would be appreciated.

Also if anyone knows some open source project that might do what I need please advice.

TIA
 
This is very speculative but...
Maybe you could subclass [tt]Component[/tt] and override the [tt]paint[/tt] method to draw your own drag tools around the 'selected' panel. Your subclass would probably need to be made the glass pane for the application (there is a [tt]setGlassPane()[/tt] method on the [tt]JInternalFrame[/tt] class.
You would use the [tt]mouseMoved[/tt] method provided by [tt]MouseMotionListener[/tt] to detect if the mouse is over one of your drag handles and change the pointer accordingly. Any drag started over one of the drag handles would then be providing a 'new size' drag box and you'd know which dimensions to update on drag finish depending upon which drag handle the drag began over.
I suspect a real solution would be a tad more complex than this though.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top