2015-09-07 11:44:36 -06:00
|
|
|
|
// ui/TextPane.java
|
2015-11-14 16:18:05 -08:00
|
|
|
|
// <20>2016 MindView LLC: see Copyright.txt
|
2015-06-15 17:47:35 -07:00
|
|
|
|
// The JTextPane control is a little editor.
|
|
|
|
|
import javax.swing.*;
|
|
|
|
|
import java.awt.*;
|
2015-11-03 12:00:44 -08:00
|
|
|
|
import java.util.function.*;
|
2015-11-11 20:20:04 -08:00
|
|
|
|
import onjava.*;
|
|
|
|
|
import static onjava.SwingConsole.*;
|
2015-06-15 17:47:35 -07:00
|
|
|
|
|
|
|
|
|
public class TextPane extends JFrame {
|
|
|
|
|
private JButton b = new JButton("Add Text");
|
|
|
|
|
private JTextPane tp = new JTextPane();
|
2015-11-03 12:00:44 -08:00
|
|
|
|
private static Supplier sg =
|
|
|
|
|
new RandomSupplier.String(7);
|
2015-06-15 17:47:35 -07:00
|
|
|
|
public TextPane() {
|
|
|
|
|
b.addActionListener(e -> {
|
|
|
|
|
for(int i = 1; i < 10; i++)
|
2015-11-03 12:00:44 -08:00
|
|
|
|
tp.setText(tp.getText() + sg.get() + "\n");
|
2015-06-15 17:47:35 -07:00
|
|
|
|
});
|
|
|
|
|
add(new JScrollPane(tp));
|
|
|
|
|
add(BorderLayout.SOUTH, b);
|
|
|
|
|
}
|
|
|
|
|
public static void main(String[] args) {
|
|
|
|
|
run(new TextPane(), 475, 425);
|
|
|
|
|
}
|
2015-09-07 11:44:36 -06:00
|
|
|
|
}
|