English 中文(简体)
涂料反应器在重新油漆后留下以前提取的图像
原标题:paintComponent() leaving behind previously drawn images after repaint()

我有一个绘画的JPanel。 每个图像有2份复印件,以表示是否选定。 一种形象是正常的,一个有色边界以表示选择。 (为了争辩,你可以认为这些形象是简单的形态)

哪一种图像是通过MouseListeners确定的。 如果用户选择图像1,那么图像1将显示其突出版本。

总的来说,这项工作在重新开始时,突出的形象留下了后面。 由于突出版本略高于正常版本,你可以看到它落后于新绘制的正常形象(过度)。

我认为,应当彻底处置目前的绘画,从头开始,这里的情况似乎就是如此。 下面是一般想法,黑板在MouseListener内gg。

因此,我的问题是,我如何使重新开始(重新)摆脱目前掌握的图像,并从头开始。

另外,如果能更简单地实现这一切,请让我知道,制作2份图像是ious的。

@Override
public void paintComponent(Graphics g){

    Graphics2D g2 = (Graphics2D) g;

    if(blackClicked)
        g2.drawImage(blackSelected,0, 0, null);
    else
        g2.drawImage(black,0, 0, null);

    g2.drawImage(green,0, 0, null);
}
最佳回答

www.un.org/Depts/DGACM/index_french.htm

您指的是,在油漆前如何用背景颜色重填充部件? 如何增加

g2.setColor(getBackground());
g2.fillRect(0, 0, getWidth(), getHeight());

页: 1

问题回答

暂无回答




相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签