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 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
| class ButtonPanel extends JPanel implements ActionListener
{
private JTextField Champ1;
private JTextField Champ2;
private JTextField Champ3;
private JButton bouton;
private TextArea Resultat;
public ButtonPanel()
{
Champ1 = new JTextField("Test1",10);
Champ2 = new JTextField("Test2",10);
Champ3 = new JTextField("Test3",10);
bouton = new JButton("Chercher ");
Resultat= new TextArea("Affichage ",100,100);
add(Champ1);
add(Champ2);
add(Champ3);
add(bouton);
add(Resultat);
bouton.addActionListener(this);
}
public void actionPerformed(ActionEvent evt)
{ System.out.println("clicked");
BE.Chercher();
}
}
class ButtonFrame extends JFrame
{
public ButtonFrame()
{
setTitle("BE JAVA ");
setSize(300,200);
addWindowListener(new WindowAdapter()
{ public void windowClosing(WindowEvent e)
{System.exit(0);
}
});
Container contentPane=getContentPane();
contentPane.add(new ButtonPanel());
}
}
public class BE {
public static void main(String[] zz)
{
JFrame frame = new ButtonFrame();
frame.show();
}
public static void Chercher()
{
Resultat.append("Afficher quelque chose de la fonction Chercher dans mon texte area"); // NE marche pas !!
}
} |
Partager