如何从jpanel中提取信息
我正在尝试一个名为白板共享的项目,其中我需要从面板获取信息,而该信息就像一些绘图,那么我如何从面板获取它。在该面板中,我正在绘制一些矩形圆圈。
I am trying a project called white board sharing in which I need to get the information from a panel and that information is like some drawings so how can I get it from a panel. In that panel I am drawing some rectangles circles.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果您想对鼠标事件做出反应,您可能需要研究 Java API 的以下部分。
MouseListener
MouseMotionListener
另外,如果您想对用户将鼠标移到绘制的元素上时触发的鼠标事件做出反应,您可能会对 Graphics2D 和实现 形状。
In case you want to react on mouse events you might want to investigate the following sections of the Java API.
MouseListener
MouseMotionListener
Also if you want to react on mouse events that are triggered when the users moves his mouse over a drawn element you might be interested in Graphics2D and the classes that implement Shape.
您可以将
Graphics
对象传递给面板,以便它绘制所绘制的项目。You can pass a
Graphics
object to the panel for it to paint the items that were drawn.将看板视为某种模型的视图可能会有所帮助,该模型记录了看板内容的抽象表示。作为一个具体示例,此
GraphPanel
有一个非常简单的模型仅包含一个List
和一个List
。这两个成员可以按照教程。It may help to think of the board as a view of some model that records an abstract representation of the board's content. As a concrete example, this
GraphPanel
has a very simple model containing nothing more than aList<Node>
and aList<Edge>
. These two members could be wrapped and serialized as discussed in this tutorial.