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 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118
|
import java.util.EventObject;
import javax.swing.JPasswordField;
import javax.swing.JLabel;
import javax.swing.JFormattedTextField;
import java.lang.Class.*;
import java.lang.Thread.*;
import java.lang.NoClassDefFoundError;
import jade.core.Runtime;
import jade.core.Agent;
import jade.core.Profile;
import jade.core.ProfileImpl;
import jade.wrapper.*;
import java.awt.Color;
import java.awt.SystemColor;
import java.awt.Button;
import javax.swing.JMenuBar;
import javax.swing.JTextField;
public class Applet3 extends JApplet
{
private JButton jButton1 = new JButton();
private JTextField jTextField1 = new JTextField();
private JLabel jLabel1 = new JLabel();
private static final String HOST= "nesrine123";
private static final int PORT= 1099;
private static final String PLATFORMID= "nesrine123"+":"+1099+"/JADE";
public Applet3()
{
}
public void init()
{
try
{;
jbInit();
}
catch(Exception e)
{
e.printStackTrace();
}
}
private void jbInit() throws Exception
{
this.getContentPane().setLayout(null);
jButton1.setText("jButton1");
jButton1.setBounds(new Rectangle(105, 40, 170, 30));
jButton1.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{try{
jButton1_actionPerformed(e);}
catch(Exception i)
{
System.err.println("Erreur Driver");
}
}
});
jTextField1.setText("jTextField1");
jTextField1.setBounds(new Rectangle(110, 130, 59, 16));
jLabel1.setText("jLabel1");
jLabel1.setBounds(new Rectangle(165, 185, 34, 14));
this.getContentPane().add(jLabel1, null);
this.getContentPane().add(jTextField1, null);
this.getContentPane().add(jButton1, null);
}
static
{
try
{
// UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
// UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
}
catch(Exception e)
{
}
}
private void jButton1_actionPerformed(ActionEvent e)throws Exception
{
System.out.println("action");
String nom= jTextField1.getText();
jLabel1.setText(nom);
try {
Runtime rt = Runtime.instance();
Profile p = new ProfileImpl(false);
Object l_Arg[] = new Object[2];
l_Arg[0] = "Arg1";
l_Arg[1] = "Arg2";
AgentContainer ac = rt.createAgentContainer(p);
AgentController myAgent1 = ac.createNewAgent(nom, mypackage1.Class1.class.getName(),l_Arg);
myAgent1.start(); //theap.start();
}
// catch (Exception e)
catch (Exception ex){ // fin du try
ex.printStackTrace();
}
}
}
} |
Partager