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
| import java.applet.*;
import java.net.*;
import java.io.*;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class ValiderHtml extends Applet implements ActionListener {
JButton send =new JButton("Connexion");
JScrollPane jscrollpane= new JScrollPane();
DefaultListModel lignes=new DefaultListModel();
JList lstURL = new JList(lignes);
BufferedReader reader = null;
String ligne;
URL url;
URLConnection conn;
public void init(){
this.setSize(900,400);
setLayout( new GridLayout(2,1));
jscrollpane.setBounds(new Rectangle(19,53,160,73));
jscrollpane.getViewport().add(lstURL,null);
send.addActionListener(this);
this.add(send);
this.add(jscrollpane);
}
public void actionPerformed(ActionEvent evt) {
Send();
}
public void Send(){
try {
url=new URL("http://<a href="http://www.developpez.com");" target="_blank">www.developpez.com");</a>
conn = url.openConnection();
reader = new BufferedReader(new InputStreamReader(conn.getInputStream()));
while ((ligne = reader.readLine()) != null) {
lignes.addElement(ligne);
}
}//fin bloc try
catch (Exception e) {
lignes.addElement("probleme1");
}
finally{
try{reader.close();}catch(Exception e){ lignes.addElement("probleme2");}
}
}// fin Send
public void paint(Graphics g) {
super.paint(g);
}
}// fin Applet |
Partager