OnJava8-Examples/gui/TextPane.java

25 lines
684 B
Java
Raw Normal View History

2015-04-20 15:36:01 -07:00
//: gui/TextPane.java
// The JTextPane control is a little editor.
import javax.swing.*;
import java.awt.*;
import net.mindview.util.*;
import static net.mindview.util.SwingConsole.*;
public class TextPane extends JFrame {
private JButton b = new JButton("Add Text");
private JTextPane tp = new JTextPane();
private static Generator sg =
new RandomGenerator.String(7);
public TextPane() {
2015-05-06 12:09:38 -07:00
b.addActionListener(e -> {
2015-05-05 14:05:39 -07:00
for(int i = 1; i < 10; i++)
tp.setText(tp.getText() + sg.next() + "\n");
2015-04-20 15:36:01 -07:00
});
add(new JScrollPane(tp));
add(BorderLayout.SOUTH, b);
}
public static void main(String[] args) {
run(new TextPane(), 475, 425);
}
} ///:~