<i id='94Xoa'><tr id='94Xoa'><dt id='94Xoa'><q id='94Xoa'><span id='94Xoa'><b id='94Xoa'><form id='94Xoa'><ins id='94Xoa'></ins><ul id='94Xoa'></ul><sub id='94Xoa'></sub></form><legend id='94Xoa'></legend><bdo id='94Xoa'><pre id='94Xoa'><center id='94Xoa'></center></pre></bdo></b><th id='94Xoa'></th></span></q></dt></tr></i><div id='94Xoa'><tfoot id='94Xoa'></tfoot><dl id='94Xoa'><fieldset id='94Xoa'></fieldset></dl></div>
    1. <small id='94Xoa'></small><noframes id='94Xoa'>

        • <bdo id='94Xoa'></bdo><ul id='94Xoa'></ul>

        <tfoot id='94Xoa'></tfoot>
        <legend id='94Xoa'><style id='94Xoa'><dir id='94Xoa'><q id='94Xoa'></q></dir></style></legend>

        将事件转发到所有组件 JAVA

        Forward event to all components JAVA(将事件转发到所有组件 JAVA)
        • <bdo id='GCIWg'></bdo><ul id='GCIWg'></ul>
          1. <i id='GCIWg'><tr id='GCIWg'><dt id='GCIWg'><q id='GCIWg'><span id='GCIWg'><b id='GCIWg'><form id='GCIWg'><ins id='GCIWg'></ins><ul id='GCIWg'></ul><sub id='GCIWg'></sub></form><legend id='GCIWg'></legend><bdo id='GCIWg'><pre id='GCIWg'><center id='GCIWg'></center></pre></bdo></b><th id='GCIWg'></th></span></q></dt></tr></i><div id='GCIWg'><tfoot id='GCIWg'></tfoot><dl id='GCIWg'><fieldset id='GCIWg'></fieldset></dl></div>
              <tbody id='GCIWg'></tbody>
          2. <small id='GCIWg'></small><noframes id='GCIWg'>

              <tfoot id='GCIWg'></tfoot>

                  <legend id='GCIWg'><style id='GCIWg'><dir id='GCIWg'><q id='GCIWg'></q></dir></style></legend>
                • 本文介绍了将事件转发到所有组件 JAVA的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我不知道如何解决这个问题.我正在开发一个图形编辑器,可以在其中绘制弧(线).我手动将弧组件的大小设置为 1000x1000,因此当拖动此弧时我不必更改它&掉了.然后我将所需尺寸的弧线绘制到该组件中.每个弧组件都安装了鼠标监听器.问题是,只有最上面的弧组件才能获得鼠标消息.我还在 JPane 本身上安装了一个鼠标单击侦听器,但是最上面的组件上的鼠标单击侦听器只会获取所有事件...很难描述这个问题,所以我将为您提供简单的图像

                  i dont how to solve this problem. I am developing a graphical editor, where arc(line) drawing is possible. I manually set the size of arc component to 1000x1000, so i dont have to change it when this arc will be dragged & dropped. Then i paint into this component the arc of the desired dimensions. Every arc components have mouse listener installed. The problem is, that only the most upper arc component get the mouse message. Also i have a mouse click listener installed on the JPane itself, but the mouse click listener on the most upper component simply gets all the events...It is kinda hard to describe this problem, so i will provide you with the simple image

                  所以第一个解决方案是以某种方式将收到的消息转发到下面的组件,但是我不知道该怎么做,所以你有什么想法吗?

                  So the first solution is to somehow forward the received message to the component that lies under, however i dont know how to do this, so do you have any ideas ?

                  第二种解决方案是,不要为弧对象设置恒定尺寸,而是以某种方式旋转该弧所在的矩形,我的意思是这样.

                  The second solution is, not to set constant dimenstion to the arc object, but somehow rotate the rectangle in which that arc will be, i mean it like this.

                  但是,仍然可能存在重叠问题.

                  however, there still can be the overlapping problem.

                  那么,您对如何解决这个问题有任何想法吗?或者如果您有任何其他想法,如何解决这个问题,我很高兴,我只需要正确的弧线会对鼠标点击做出反应.

                  So, do you have any ideas how to solve this problem ? or if you have any other ideas, how to solve this, id be happy, i simply need that the correct arc will react to the mouse click.

                  我不认为我的代码会有所帮助,但在这里

                  I dont think that the my code will somehow helps, but here it is

                  arcObject.setSize(1000, 1000); // !
                  

                  然后,在这个组件中,我画了一个圆弧

                  and then, in this component i draw an arc

                  toX = o2.x - 24 * Math.cos(theta);
                  toY = o2.y - 24 * Math.sin(theta);
                  g2.draw(new Line2D.Double(toX, toY, o1.x, o1.y));
                  

                  推荐答案

                  我是这样解决的:

                  1. 将所有创建的弧保存到列表中
                  2. 当鼠标点击时,循环遍历所有弧线
                  3. 创建新的 Line2D 对象,将圆弧的参数保存在列表中,如下所示:

                  1. save all created arcs to the List
                  2. when mouse clicked, loop through all the arcs
                  3. create new Line2D object, with the parameters of the arc saved in the list, like this:

                  Line2D 线 = 新 Line2D.Double(...)

                  Line2D line = new Line2D.Double(...)

                  检查这个条件

                  if (line.ptLineDist(x, y) < 3) {...//我们点击了就行了,做点什么

                  if (line.ptLineDist(x, y) < 3) { ... //we clicked on the line, do something

                  }

                  这篇关于将事件转发到所有组件 JAVA的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Lucene Porter Stemmer not public(Lucene Porter Stemmer 未公开)
                  How to index pdf, ppt, xl files in lucene (java based or python or php any of these is fine)?(如何在 lucene 中索引 pdf、ppt、xl 文件(基于 java 或 python 或 php 中的任何一个都可以)?)
                  KeywordAnalyzer and LowerCaseFilter/LowerCaseTokenizer(KeywordAnalyzer 和 LowerCaseFilter/LowerCaseTokenizer)
                  How to search between dates (Hibernate Search)?(如何在日期之间搜索(休眠搜索)?)
                  How to get positions from a document term vector in Lucene?(如何从 Lucene 中的文档术语向量中获取位置?)
                  Java Lucene 4.5 how to search by case insensitive(Java Lucene 4.5如何按不区分大小写进行搜索)
                    <bdo id='zO2xv'></bdo><ul id='zO2xv'></ul>
                        <tbody id='zO2xv'></tbody>
                          <legend id='zO2xv'><style id='zO2xv'><dir id='zO2xv'><q id='zO2xv'></q></dir></style></legend>
                          <tfoot id='zO2xv'></tfoot>
                        • <i id='zO2xv'><tr id='zO2xv'><dt id='zO2xv'><q id='zO2xv'><span id='zO2xv'><b id='zO2xv'><form id='zO2xv'><ins id='zO2xv'></ins><ul id='zO2xv'></ul><sub id='zO2xv'></sub></form><legend id='zO2xv'></legend><bdo id='zO2xv'><pre id='zO2xv'><center id='zO2xv'></center></pre></bdo></b><th id='zO2xv'></th></span></q></dt></tr></i><div id='zO2xv'><tfoot id='zO2xv'></tfoot><dl id='zO2xv'><fieldset id='zO2xv'></fieldset></dl></div>

                          <small id='zO2xv'></small><noframes id='zO2xv'>