开发者

Drag and drop widgets in Java 2D

开发者 https://www.devze.com 2023-02-22 06:22 出处:网络
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 ha

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:

  1. When a user presses the mouse button your application goes to a "drag" mode
  2. When repaint() method is called while you're in drag mode you move your widget position to the coordinates of the cursor
  3. 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.

0

精彩评论

暂无评论...
验证码 换一张
取 消