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
|
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JApplet;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JTextField;
public class FirstApplet extends JApplet {
/**
*
*/
private static final long serialVersionUID = 1L;
private JLabel label = new JLabel();
private JButton bouton = new JButton("Individu");
private JTextField input = new JTextField();
private int count = 0;
/**
* Méthode d'initialisation de l'applet C'est cette méthode qui fait office
* de constructeur
*/
public void init() {
this.setSize(600, 80);
// On centre le texte du JLabel et on écrit en bleu...
label.setHorizontalAlignment(JLabel.CENTER);
// C'est plus zoli.
label.setForeground(Color.blue);
// Allez, une classe anonyme... Just for the fun ;)
this.bouton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
// Paramètres de connexion
String databaseURL = "jdbc:firebirdsql:file:///E:/Users/Fred/Documents/Généalogie/Ancestrologie/database/MA_BASE.bdd";
// String databaseURL = "jdbc:firebirdsql://localhost/E:/Users/Fred/Documents/Généalogie/Ancestrologie/database/MA_BASE.bdd";
String user = "SYSDBA";
String password = "masterkey";
String driverName = "org.firebirdsql.jdbc.FBDriver";
java.sql.Driver d = null;
java.sql.Connection c = null;
// Version driver
try {
Class.forName(driverName);
label.setText("Driver OK");
} catch (java.lang.ClassNotFoundException e) {
// A call to Class.forName() forces us to consider this
// exception :-)...
System.out
.println("ERROR Firebird JCA-JDBC driver not found in class path");
System.out.println(e.getMessage());
label.setText("ERROR Firebird JCA-JDBC driver not found in class path");
}
}
});
// On ajoute nos composants
this.getContentPane().add(bouton, BorderLayout.SOUTH);
this.getContentPane().add(label, BorderLayout.CENTER);
this.getContentPane().add(input, BorderLayout.NORTH);
// Et le tour est joué !
System.out.println("Paramètre passé via la balise <param> : "
+ this.getParameter("message"));
}
} |
Partager