连接两个 JInternalFrame 实例的 CubicCurve2D
我一直在尝试找到一种方法(在 Swing 中)将两个 JInternalFrame 与 CubicCurve2D (也称为三次贝塞尔曲线)连接。我试图实现的总体效果是一个类似于 Yahoo! 的界面。管道(曲线应从一个内部框架的底部延伸到另一个内部框架的顶部)。
这里有人以前做过这个吗?我遇到的问题是我无法弄清楚如何以用户可见的方式绘制更新曲线。绘制然后重新绘制JDesktopPane.getGraphics
似乎没有做任何事情。
如果可能的话,我想使用屏幕外缓冲区。
I have been trying to find a way (in Swing) to connect two JInternalFrame
s with a CubicCurve2D
(otherwise known as a cubic bezier curve). The overall effect I'm trying to achive is an interface similar to Yahoo! Pipes (the curve should go from the bottom of one internal frame to the top of the other).
Has anybody here done this before? The issue I am running into is that I cannot figure how to draw an updating curve in a way which is visible to the user. Drawing to and then repainting JDesktopPane.getGraphics
doesn't seem to do anything.
If possible, I would like to use an offscreen buffer.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
是的。下面是一个使用
drawLine(int x1, int y1, int x2, int y2)
的示例,但在曲线上调用draw(Shape s)
是一个简单的扩展。您可能还需要扩展 ComponentAdapter 来处理调整大小事件。Yes. Here's an example using
drawLine(int x1, int y1, int x2, int y2)
, but invokingdraw(Shape s)
on your curve is a straightforward extension. You may have to expand theComponentAdapter
to handle resize events, too.试试这个。我刚刚修改了上面给出的代码。
Try this. I just modified the code given above.