import java.awt.Component; import java.awt.Dimension; import java.awt.Frame; import java.awt.Graphics; import java.awt.ScrollPane; import java.awt.Window; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; public class Window2AWT { public static void main(String[] args) { Frame frame = new Frame("AWT Window"); frame.setSize(300, 200); // width, height ScrollPane scrollpane = new ScrollPane(); // Put the scrollpane into the frame. frame.add(scrollpane); // Put a big, black circle into the scrollpane. scrollpane.add(new Component() { public void paint(Graphics g) { g.fillOval(0, 0, 400, 400); } public Dimension getPreferredSize() { return new Dimension(400, 400); } }); frame.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { Window window = e.getWindow(); window.dispose(); } }); frame.setVisible(true); } }