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 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93
|
import java.sql.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class ClasseDD implements ActionListener
{
Frame1 ff = new Frame1();
Frame f;
Panel pan;
Label lnom, lprenom;
TextField tnom, tprenom;
Button but;
GridLayout grid;
public ClasseDD()
{
f = new Frame ("hello");
f.setSize (300,100);
f.setVisible(true);
pan = new Panel();
grid = new GridLayout(3,2);
pan.setLayout(grid);
lnom = new Label("nom");
tnom = new TextField();
lprenom = new Label("prenom");
tprenom = new TextField();
but = new Button("go");
pan.add(lnom);
pan.add(tnom);
pan.add(lprenom);
pan.add(tprenom);
pan.add(but);
but.addActionListener(this);
f.add(pan);
}
public void actionPerformed (ActionEvent e)
{
if (e.getSource().equals(but))
{
ConnexionBdd cb = new ConnexionBdd();
Statement stmt = cb.stat();
try {
ResultSet resultat;
resultat = stmt.executeQuery(
"SELECT nom FROM fl" );
while (resultat.next()) {
String nom = resultat.getString("nom");
System.out.println(nom);
Frame1 fff = new Frame1();
Label labb = fff.l();
labb.setText(nom);
}
} catch (SQLException e1) {
e1.printStackTrace();
}
}
}
public static void main (String args[])
{
ClasseDD cbb = new ClasseDD();
}
} |
Partager