Domanda

I got a pretty big problem. I am writing a GUI with following structure:

MainFrame ( MainPanel ( JScrollPane ( ContentPanel ( Content1,Content2,Content3 ) ) ) )

There is also a GlassPane over the MainFrame. There is a Timer in the GlassPane Class, which ticks about every 100ms.

This Timer is updating the value of a JSlider of Content1. The JSlider also has a change listener which gives the current X-Coordinate of the thumb to the GlassPane. These coordinate is used to draw a line every tick, if it changed. This line goes over Content1,Content2 and Content3.

I am currently trying to update these contents via this.repaint(), MainPanel.repaint(), this.repaint(Rectangle), MainPanel.repaint(Rectangle).

Unfortunately all these Methods (even the repaint(Rectangle) o0 ) call the paintComponent Methods of Content1, Content2 and Content3, what somehow creates a cyclic repaint. I cannot explain this cycle and am pretty desperate already. I would be very thankful for any help or suggestion.

I would really like to give you some code too, but its so much. And I dont really know what would be useful.

Greets, Corn

È stato utile?

Soluzione

It is enough to do this.repaint() on the JFrame, it repaints all Objects (Components) that are on the JFrame.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top