I'm new to Java so this is probably pretty simple, but I'm not sure how to make it work.
Basically, I have a class which I use to draw a grid, which extends JPanel. I put this class in a window, inside a JScrollPane. The scroll works the way I want it to, except the drawing inside my class doesn't update itself once the window scrolls. It does update if the window is resized though.
I think I'm supposed to use events/listeners or something like that, but I'm not sure where to start looking.
edit: also, when i open one of the menus and it overlaps on the drawing, the region that was covered by the menus isn't updated.
Okay, let's try again: I have a class called draw. Then I have a GridBagLayout out of draws. This creates the grid I need. I have an object moving around the grid, so this way I can update the grid without having to calculate myself the rectangles that have to be updated.
Then this grid is inside a JScrollPane, which is not subclassed. I use pack() when I create my Window, but the thing is, the Window may be bigger than the resolution allows, so I need it to be scrollable. The scroll works for me, but it doesn't update the image when I use it. However, resizing the window does update it.
What I want is a way to redraw all my window when I click the JScrollPane. And now, I also need to redraw the whole thing (or some parts, I'll see that later) once I access the menus, because the draw parts of the grid under the menus are not updated.
That's the best way I can describe it.