ex14

来源:互联网 发布:淘宝网上开店要钱吗 编辑:程序博客网 时间:2024/05/22 06:55
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);    }}
0 0
原创粉丝点击