How do I create scroll bars inside a dialog?

John Zukowski

The Dialog component itself doesn't provide scrollbars. If you want to make them available, you have to place your set of components within a Container like a Panel, then place that container within a ScrollPane to provide the scrollbars.

Dialog dialog = new Dialog(mainFrame);
dialog.setLayout(new GridLayout(1,0));
Panel content = new Panel();
// set layout and add components for dialog to content panel

ScrollPane pane = 
    new ScrollPane(ScrollPane.SCROLLBARS_AS_NEEDED);

Note that if you are using Swing, you'll want to use JScrollPane instead of ScrollPane.