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
|
import java.awt.Color;
import java.awt.Dimension;
import javax.swing.BorderFactory;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
public class TestScrollBar extends JFrame{
public TestScrollBar()
{
setLayout(null);
setSize(300,300);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setResizable(false);
JTextArea textAreaComment = new JTextArea();
JScrollPane textAreaScrollPane = new JScrollPane(textAreaComment);
textAreaComment.setBounds(10, 10, 200, 50);
textAreaScrollPane.setLayout(null);
textAreaScrollPane.setBounds(10, 10, 200, 50);
textAreaScrollPane.setBorder(BorderFactory.createLineBorder(Color.BLACK));
//frame.add(textAreaScrollPane);
JPanel p = new JPanel();
p.setLayout(null);
p.add(textAreaScrollPane);
p.setBounds(0, 0, 500, 500);
setSize(800,600);
setVisible(true);
this.add(p);
}
public static void main(String[] args) {
TestScrollBar t = new TestScrollBar();
}
} |
Partager