ex14

package exercise;

import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;

import net.mindview.util.Generator;
import net.mindview.util.RandomGenerator;

import static net.mindview.util.SwingConsole.*;

public class ex14 extends JFrame {

    private JButton bn = new JButton("add text");
    private JTextArea txt = new JTextArea();
    private static Generator sg = new RandomGenerator.String(7);

    public ex14() {
        bn.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                for (int i = 0; i < 10; i++) {
                    txt.setText(txt.getText() + sg.next() + "\n");
                }
            }
        });
        add(new JScrollPane(txt));
        add(BorderLayout.SOUTH, bn);
    }

    public static void main(String[] args) {
        run(new ex14(), 500, 400);
    }
}

你可能感兴趣的:(ex14)