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 38
|
import javax.swing.*;
import java.awt.event.*;
public class TestClasses extends JFrame implements ActionListener {
JFrame frame1 = new JFrame();
JButton bouton = new JButton("Valider");
JTextArea area = new JTextArea(5,5);
String lineSeparator = System.getProperty("line.separator");
public TestClasses() {
frame1.setSize(500,200);
frame1.setLocation(0,300);
frame1.add(area);
frame1.setVisible(true);
setSize(500,200);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JPanel panel=new JPanel();
panel.add(bouton);
add(panel);
bouton.addActionListener(this);
setVisible(true);
}
public static void main(String[] args) {
TestClasses t = new TestClasses();
}
public void actionPerformed(ActionEvent e) {
test("coucou" + lineSeparator);
}
public void test(String type) {
area.append(type);
}
} |
Partager