I have this program, where I have a canvas in a window with 2 circles in it (you can move one of the circles by clicking on the canvas).
It works with no problems on windows and iOS, but it has this problem on ubuntu:
When I change the selected circle with the combobox in the top left corner of the window, the circles disappears and are only visible in the top left corner of the canvas in the area which was covered by the combobox items right before I swiched the selected circle.
Also when I drag the application window so it leaves the screen or put another window over my window, the circles start to be visible in the part of the canvas which was hidden.
Can you please explain, why is this happening and what am I doing wrong?
The code of my program is here: http://pastie.org/private/rm0gw2awx6d7iztyabzs7q
You're breaking the paint chain, you should be calling
super.paint
, but in the case of theJPanel
, you should be overridingpaintComponent
(and callingsuper.paintComponent
before you do any custom painting)Take a look at Painting in AWT and Swing and Performing Custom Painting for more details