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 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145
| /*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package ais;
import static java.awt.image.ImageObserver.WIDTH;
import java.io.BufferedReader;
import java.io.StringReader;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
/**
*
* @author Seb et Lae
*/
public class Accueil extends javax.swing.JFrame implements Runnable {
public String NewsMsg;
Thread t=null;
BufferedReader _monbuf;
int ClinetPortNumber;
/**
* Creates new form Accueil
*/
public Accueil() {
initComponents();
NewsMsg = null;
//super("News Client");
}
public void Setup(int ClientPort)
{
ClinetPortNumber=ClientPort;//ClientPort;
t=new Thread(this);
t.start();
}
@SuppressWarnings("unchecked")
private void exitMenuItemActionPerformed(java.awt.event.ActionEvent evt) {
System.exit(0);
}
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(Accueil.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(Accueil.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(Accueil.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(Accueil.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
//</editor-fold>
final Accueil ob = new Accueil();
ob.Setup(6020);
/* Create and display the form */
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new Accueil().setVisible(true);
while(true)
{
try
{
try (DatagramSocket ClientSoc = new DatagramSocket(6020)) {
byte Receivebuff[]=new byte[1024];
DatagramPacket dp=new DatagramPacket(Receivebuff,Receivebuff.length);
ClientSoc.receive(dp);
ob.NewsMsg = new String(dp.getData(),0,dp.getLength());
BufferedReader entree = new BufferedReader(new StringReader(ob.NewsMsg));
ClientSoc.close();
Thread.sleep(50);
AcqAIS miact = new AcqAIS(ob.NewsMsg, null);
ob.jTextArea1.setText(miact.resultat);
}
}
catch(Exception ex)
{
ex.printStackTrace();
}
}
}
});
}
// Variables declaration - do not modify
private javax.swing.JMenuItem aboutMenuItem;
private javax.swing.JMenuItem contentsMenuItem;
private javax.swing.JMenuItem copyMenuItem;
private javax.swing.JMenuItem cutMenuItem;
private javax.swing.JMenuItem deleteMenuItem;
private javax.swing.JMenu editMenu;
private javax.swing.JMenuItem exitMenuItem;
private javax.swing.JMenu fileMenu;
private javax.swing.JMenu helpMenu;
private javax.swing.JButton jButton1;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JTextArea jTextArea1;
private eu.hansolo.steelseries.extras.Led led1;
private javax.swing.JMenuBar menuBar;
private javax.swing.JMenuItem openMenuItem;
private javax.swing.JMenuItem pasteMenuItem;
private javax.swing.JMenuItem saveAsMenuItem;
private javax.swing.JMenuItem saveMenuItem;
// End of variables declaration
@Override
public void run() {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
} |
Partager