Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 11 years ago.
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(5)
当然,您可以使用 Swing 来做到这一点。您可能想研究一下 Java 的 Shape 图书馆。
或者,您可以简单地重写组件的绘制方法,如下所示。
Sure you can do that using Swing. You may want to look into Java's Shape library for that.
Alternatively you can simply override the Component's paint method as shown below.
Java2D API 可以满足您的需求。
The Java2D API has what you are looking for.
查看自定义绘画方法了解一些想法。 DrawOnComponent 更接近您想要的。需要更改它才能将自定义形状对象添加到列表中。
Check out Custom Painting Approaches for a couple of ideas. The DrawOnComponent is closer to what you want. It would need to be changed to add your custom shape objects to the list.
GraphPanel
是一个对象绘制程序的简单示例,其功能可移动、可调整大小、由边缘连接的彩色节点。GraphPanel
is a simple example of an object drawing program that features moveable, resizable, colored nodes connected by edges.Java 2D 是您绘制图形所需要的(即,绘制彩色矩形、圆形、线条并为它们设置动画)。
Java 2D is what you neede drawing graphics (i.e., draw colored rectangles, circles, lines, and animate them).