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 27 28 29 30 31 32 33 34 35 36 37
|
import javax.swing.*;
import java.util.*;
import java.awt.event.*;
public class conversion extends JFrame{
JTextArea ta = new JTextArea(4,10);
JButton b = new JButton("GetText");
String x;
public conversion() {
super("Conversion");
setBounds(300,300,200,150);
show();
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JPanel p =new JPanel();
p.add(ta);
b.addActionListener( new ActionListener() {
public void actionPerformed(ActionEvent e) {
x=ta.getText();
StringTokenizer n = new StringTokenizer(x,"\n");
while (n.hasMoreElements()) {
System.out.println(" "+n.nextToken());
}
}
});
p.add(b);
setContentPane(p);
}
public static void main (String[] args) {
conversion conver = new conversion();
}
} |
Partager