I trying to make a game where I add a Canvas to a JScrollPane but the canvas is larger than the visible area of the JScrollPane. So when I scroll the JScrollPane to see the rest I only see the blank area even though my Canvas is continuously redrawn. Anybody can help me??
It is common JScrollPane problem. To fix this with minimum fuss, call the following methods on your JScrollPane:
scrollpane.getViewport().setScrollMode(JViewport.SIMPLE_SCROLL_MODE);
Swing components do not work with heavyweight AWT components like Canvas. Use a JComponent or a JPanel instead of a Canvas
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With