Is there any material/tutorials available that can shed some light on creating drap and drop widgets with Java 2D? I am not talking about drag and drop data transfer like here. What I want to do is have a visual pane in my application, wh开发者_C百科ere users can create widgets, connect them to each other etc. Something like a creating a graph, but with widgets that have properties.
Thanks.
This is generally works like this:
- When a user presses the mouse button your application goes to a "drag" mode
- When repaint() method is called while you're in drag mode you move your widget position to the coordinates of the cursor
- When mouse button is released you fixate the ultimate position of the windget.
The simple illustration for this might be a program I was writing in my youth - interactive chess board. Here is relevant class that includes pieces dragging capabilities http://jinyan.svn.sourceforge.net/viewvc/jinyan/trunk/jinyan/client/src/net/sfficslecview/lvboard/EditableChessBoard.java?revision=77&view=markup
I have found the perfect solution. I can make use of the Netbeans Visual Library by extracting jar from the Netbeans Platform.
精彩评论