Whilst I've been searching and reading these forums for a couple of months now, I've had to register as I've got an issue that Googling just can't fix!
I have a main panel on the frame, and a transparent glass panel over this. Here are the main steps in my program:
1) Glasspane visibility set to false. I then draw circles upon the main panel
2) Glasspane visibility set to true and update text on this (which should appear 'above' the circles)
3) Glasspane visibility set to false and I recolour these circles
Problem is, as soon as I update the text on the glasspanel, the circles beneath disappear, not appearing again until I redraw them. I know that I should be using threading, so I can't understand why this doesn't work:
Thank you Pete. My code is very large so reducing it down to a workable example will take a while, I'll get started. In the mean time, it may be useful to know that:
I draw the circles on the main panel by:
and I am 'drawing' on the glass panel by updating the text in a JLabel present on it:
I've had a look in a few of my reference books and is it possible that I need to override the glass pane's paint method? If I set it's visibility to true before I start drawing the circles, it appears beneath these circles. Why isn't the glass pane always staying on top?
Sorry about all the questions - I hope you can help me further! Thanks again.
Mikko Kohtamäki wrote:And invokeLater can be (or should be) called only from EDT thread.
Nonsense. invokeLater can be called from any thread, including the EDT. It is used if you want something to be done on the EDT but it can finish at some later time. invokeAndWait cannot be called from the EDT (throws an exception), and is used if you need the GUI update to be done before continuing with the remainder of the thread.