1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
|
import java.awt.Dimension;
import javax.swing.Box;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
public class TestScrollPanel extends JFrame
{
public TestScrollPanel()
{
JPanel p = new JPanel();
Box box = Box.createVerticalBox();
box.setPreferredSize(new Dimension(150, 500));
JLabel label0 = new JLabel("TestScrollPane0");
JTextArea area = new JTextArea(5,10);
JLabel label1 = new JLabel("TestScrollPane1");
JLabel label2 = new JLabel("TestScrollPane2");
JLabel label3 = new JLabel("TestScrollPane3");
JLabel label4 = new JLabel("TestScrollPane4");
JLabel label5 = new JLabel("TestScrollPane5");
box.add(label0);
box.add(new JScrollPane(area));
box.add(label1);
box.add(label2);
box.add(label3);
box.add(label4);
box.add(label5);
p.add(box);
add(new JScrollPane(p));
setPreferredSize(new Dimension(150, 300));
}
public static void main(String[] args)
{
TestScrollPanel t = new TestScrollPanel();
t.pack();
t.setVisible(true);
}
} |
Partager