bonsoir je fait une applet qui essaie de recuperer l addresse ip d une url
mais voila sa ne marche pas j ai une tonne d erreur
voila mon code
j ai essayer ven ligne de commande sur un autre petirt programme que voici
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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 import java.applet.*; import java.net.*; import javax.swing.*; import java.awt.*; import java.awt.event.*; public class Appdns extends JApplet{ public void init(){ JFrame jf=new JFrame("resolution"); JPanel jp=new JPanel(); jp.setLayout(new GridLayout(1,2)); JLabel jl=new JLabel(" Url"); final JTextField jtf=new JTextField(36); jp.add(jl); jp.add(jtf); JPanel jp2=new JPanel(); jp2.setLayout(new GridLayout(1,1)); JButton jb=new JButton("resoudre"); jb.addActionListener(new Actions(jtf)); jp2.add(jb); jf.getContentPane().add("Center",jp); jf.getContentPane().add("South",jp2); jf.setSize(300,100); jf.setVisible(true); } } class Actions implements ActionListener{ private JTextField jtf; public Actions(JTextField j){jtf=j;} public void actionPerformed(ActionEvent e){String add=jtf.getText(); try{ InetAddress ina=InetAddress.getByName(add); jtf.setText(ina.toString()); } catch(UnknownHostException ex){ jtf.setText("UnknownHost"); } } }
et la ca marche
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9 import java.net.*; public class Dns{ public static void main(String[] args){ try { InetAddress ina=InetAddress.getByName(args[0]);System.out.println(ina.toString());} catch(UnknownHostException e){ System.out.println(e);} } }
je pense que je que sa viens de l action du bouton qui pose probleme jae crois que j avis fait comme ca mais je me souviens plus tres bien si qq peu m aider au secours .
Partager