Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Putting JDesktopPane inside JScrollPane

291 views
Skip to first unread message

Michiel de Roo

unread,
Sep 13, 2001, 11:26:20 AM9/13/01
to
Hi,

Does anyone know a way to put a JDesktopPane inside a JScrollPane. I
want to develop sort of a virtual desktop that is larger than the
screen, like in many Linux window managers.

Michiel.

Bruno Stocker

unread,
Sep 14, 2001, 11:01:46 AM9/14/01
to

"Michiel de Roo" <mic...@belangrijkDELETETHIS.nl> schrieb im Newsbeitrag
news:3ba0cf7c....@news.uu.nl...

This example may give you some ideas:

import java.awt.*;
import javax.swing.*;
import java.util.*;


public class ScrollPaneTest extends JFrame{
public ScrollPaneTest(){
brInit();
}

public void brInit(){
JScrollPane scroll = new JScrollPane();
scroll.setPreferredSize(new Dimension(200,200));
JDesktopPane pane = new JDesktopPane();
pane.setPreferredSize(new Dimension(400,400));
JInternalFrame internal = new JInternalFrame("Frame");
internal.getContentPane().add(new JButton("Test"));
internal.pack();
internal.setVisible(true);
pane.add(internal);
JInternalFrame internal2 = new JInternalFrame("Frame");
internal2.getContentPane().add(new JButton("Test2"));
internal2.pack();
internal2.setVisible(true);
pane.add(internal2);
scroll.getViewport().add(pane);
this.getContentPane().add(scroll);
}

public static void main(String[] args){
ScrollPaneTest frame = new ScrollPaneTest();
frame.pack();
frame.setVisible(true);
}

}

Greetings
Bruno


0 new messages