//leftpane.setPreferredSize(new Dimension(200,500));
//rightpane.setPreferredSize(new Dimension(266,500));
//mainpane.setPreferredSize(new Dimension(900,500));
//mainpane.setLayout(new FlowLayout());
//toppane.setPreferredSize(new Dimension(1366,150));
Don't use setPreferredSize() on any component. The layout manager of the panel with determine the preferred size for the panel. Then the scrollbars will appear automatically when required.
Also, FlowLayout is the default layout for a panel so you don't need to manually set the layout again.