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
| import java.util.* ;
import javax.swing.* ;
import java.awt.*;
import java.awt.event.*;
public class Dialogue implements ActionListener
{
private JFrame fen = new JFrame("Boite De Dialogue"); //creation d'une fenetre
private JButton bok = new JButton("OK");
public JPanel Pdessus = new JPanel(new FlowLayout());
public static String txt;
private JTextField texte = new JTextField();
private static int bip=0;
/**
* le programme principal qui cree les objets Dialogue de reponse
*/
public static void main(String[] args)
{
new Dialogue();
new Reponse(txt); //probleme ici
}
public Dialogue()
{
JPanel panneauPrinc = new JPanel( new BorderLayout() );
//txt = JOptionPane.showInputDialog(null,"taper un mot");
panneauPrinc.add(texte,BorderLayout.NORTH);
panneauPrinc.add(Pdessus,BorderLayout.SOUTH);
Pdessus.add(bok);
fen.setContentPane(panneauPrinc);
fen.pack();
fen.setVisible(true);
}
/**
* gestion des boutons
*/
public void actionPerformed (ActionEvent evt)
{
if (evt.getSource()==bok)
{
txt=texte.getText();
System.out.println(txt);
bip=1;
}
}
} |