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);
            
pane.add(content);
dialog.add(pane);

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

0 Comments  (click to add your comment)
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

About | Sitemap | Contact