The good news is there is already a scrollable container as part of the java.awt package. It's called ScrollPane, and without this, you'd need to create one from scratch, using scrollbars.
Its easy to create an instance of ScrollPane, and to then add it to your applet or application. Simply create a new instance of ScrollPane, and then add it to your applet's canvas. Whatever size your applet is, the scroll pane will adjust to. Now as you add components, scroll bars will appear as needed. You can also change the size of the scrollbar via the setSize() method. Here's a quick example:
// Create a scroll pane object ScrollPane myContainer = new ScrollPane();
// Add scroll pane to your current canvas add(myContainer); // Now you can add components to your container
Posted in: Java