简体   繁体   English

如何从jpanel中提取信息

[英]how to extract information from 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. 在该面板中,我正在绘制一些矩形圆。

In case you want to react on mouse events you might want to investigate the following sections of the Java API. 如果您想对鼠标事件做出反应,则可能需要研究Java API的以下部分。

MouseListener 鼠标监听器

MouseMotionListener 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 . 同样,如果您想对用户将鼠标移到绘制的元素上时触发的鼠标事件做出反应,则可能对Graphics2D和实现Shape的类感兴趣。

您可以将Graphics对象传递给面板以绘制所绘制的项目。

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 a List<Node> and a List<Edge> . 作为一个具体示例,此GraphPanel具有一个非常简单的模型,其中仅包含List<Node>List<Edge> These two members could be wrapped and serialized as discussed in this tutorial . 这两个成员可以按照本教程中的说明进行包装和序列化。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM