JScrollPane pane = new JScrollPane(component);
Name in
Design Pattern |
Actual Name
(scroll bars) |
Component | Component |
ConcreteComponent | JTextArea |
Decorator | JScrollPane |
method() |
a method of Component (e.g. paint) |
ScrollPaneTest.java
import java.awt.*; import javax.swing.*; public class ScrollPaneTest { public static void main(String[] args) { JFrame frame = new JFrame(); Container contentPane = frame.getContentPane(); JTextArea area = new JTextArea(20, 40); // 20 rows, 40 columns JScrollPane scroller = new JScrollPane(area); contentPane.add(scroller, BorderLayout.CENTER); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setSize(200, 200); frame.setVisible(true); } }
Maintained by John Loomis, updated Sun Feb 25 21:40:04 2007