I’m building this small java applet in which I need a JPanel which will support a scroll bar. I’ve tried different solutions, including scrollpanes and so forth, they worked fine when I used them in java applications and in IFrames, but from some reason when I moved them to java applets and inside other panels instead of JFrames they scrollbar just did not appear.
What I am trying to do is build a small app, with an expending Graphic2d (it changes through time), once it reaches a certain width I want a scroll panel to appear and allow moving throughout it.
Thank you!
Scrollbars appear automatically when the “preferred size” of the component added to the viewport of the scrollpane is greater than the size of the scrollpane.
Since you are doing custom painting on the panel, you are responsible for setting the preferred size of the panel as it changes.