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");
}
}
} |
Partager