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
|
import java.awt.*;
import javax.swing.*;
public class TextDemo {
public TextDemo() {
JFrame frame = new JFrame("Test");
frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
frame.setSize(400, 300);
frame.setLocationRelativeTo(null);
JTextArea code = new JTextArea();
//ton code:
JScrollPane scrollbar = new JScrollPane(code);
scrollbar.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
//
frame.add(scrollbar);
frame.setVisible(true);
}
public static void main(final String args[]) {
EventQueue.invokeLater(new Runnable() {
@Override
public void run() {
TextDemo test = new TextDemo();
}
});
}
} |