JPanel scrollPane = new JPanel(); scrollPane.setLayout(new BorderLayout()); Scrollbar vertical = new Scrollbar(Scrollbar.VERTICAL); Scrollbar horizontal = new Scrollbar(Scrollbar.HORIZONTAL); scrollPane.add(bv, BorderLayout.CENTER); scrollPane.add(vertical, BorderLayout.EAST); scrollPane.add(horizontal, BorderLayout.SOUTH);
JScrollPane scrollPane = new JScrollPane(bv); bv.setScrollbars(scrollPane.getVerticalScrollBar(), scrollPane.getHorizontalScrollBar());
    private void setupFrame() {        frame.setTitle(Messages.getString("BoardEditor.title")); //$NON-NLS-1$        frame.getContentPane().setLayout(new BorderLayout());        // Create a scroll bars to surround the board view.        JPanel scrollPane = new JPanel();        scrollPane.setLayout(new BorderLayout());        Scrollbar vertical = new Scrollbar(Scrollbar.VERTICAL);        Scrollbar horizontal = new Scrollbar(Scrollbar.HORIZONTAL);        scrollPane.add(bv, BorderLayout.CENTER);        scrollPane.add(vertical, BorderLayout.EAST);        scrollPane.add(horizontal, BorderLayout.SOUTH);        frame.getContentPane().add(scrollPane, BorderLayout.CENTER);        // Assign the scrollbars to the board viewer.        bv.setScrollbars(vertical, horizontal);        frame.getContentPane().add(this, BorderLayout.EAST);        menuBar.addActionListener(this);        frame.setMenuBar(menuBar);        frame.setBackground(SystemColor.menu);        frame.setForeground(SystemColor.menuText);        if (GUIPreferences.getInstance().getWindowSizeHeight() != 0) {            frame.setLocation(GUIPreferences.getInstance().getWindowPosX(), GUIPreferences.getInstance().getWindowPosY());            frame.setSize(GUIPreferences.getInstance().getWindowSizeWidth(), GUIPreferences.getInstance().getWindowSizeHeight());        } else {            frame.setSize(800, 600);        }        // Give the scrollbars large initial values.        horizontal.setVisibleAmount(frame.getSize().width);        vertical.setVisibleAmount(frame.getSize().height);        // when frame is closing, just hide it        frame.addWindowListener(new WindowAdapter() {            public void windowClosing(WindowEvent e) {                frame.setVisible(false);                setMapVisible(false);            }        });    }