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 94 95 96 97 98 99 100 101 102
|
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
import java.net.*;
public class LanceAppli extends Applet implements TextListener, ActionListener {
/**
*
*/
private static final long serialVersionUID = -7712116006950478375L;
/**
* @param args
*/
TextField login,pwd;
Button validation, annulation;
String commande,cmd;
public void init() {
// TODO Auto-generated method stub
if (getParameter("commande")!=null)
{
cmd=getParameter("commande") ;
}
else
{
//annuler();
cmd="notepad";
}
if (cmd!=null){
setBackground(Color.orange);
add(new Label("Identifiant : "));
add(login = new TextField(20));
add(new Label("Mot de passe : "));
add(pwd = new TextField(20));
add(validation = new Button ("Valider"));
add(annulation = new Button ("Annuler"));
validation.addActionListener(this);
annulation.addActionListener(this);
}
}
public void actionPerformed(ActionEvent e) {
commande = e.getActionCommand();
if (commande.equals("Valider"))
{
valider();
}
else
{
annuler();
}
}
public void valider()
{
try {
Runtime.getRuntime().exec(cmd);
} catch (Exception e)
{
try
{
getAppletContext().showDocument(new URL("javascript:console.log("+e.getMessage()+")"));
}
catch (MalformedURLException me) { }
}
try {
getAppletContext().showDocument
(new URL("javascript:LANCEAPPLI.valider('valider')"));
}
catch (MalformedURLException me) { }
}
public void annuler()
{
try {
getAppletContext().showDocument
(new URL("javascript:LANCEAPPLI.annuler('annuler')"));
}
catch (MalformedURLException me) { }
}
public void textValueChanged(TextEvent e) {
// TODO Auto-generated method stub
}
} |
Partager