1 IP Lookup with java [Problem] 18th January 2010, 8:13 pm
C0D3R
MITR Master
ေအာက္ကကုတ္ေလးကေတာ႔ အိုင္ပီၾကည္႔ဖို႕အတြက္ java ကုတ္ေလးပါ
- Code:
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
import java.net.*;
public class ip extends JFrame {
// Anfang Attribute
private JTextField jTextField1 = new JTextField();
private JLabel jLabel1 = new JLabel();
private JButton jButton1 = new JButton();
// Ende Attribute
public ip (String title) {
// Frame-Initialisierung
super (title);
setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
int frameWidth = 263;
int frameHeight = 199;
setSize(frameWidth, frameHeight);
Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
int x = (d.width - getSize().width) / 2;
int y = (d.height - getSize().height) / 2;
setLocation(x, y);
Container cp = getContentPane();
cp.setLayout(null);
// Anfang Komponenten
jTextField1.setBounds(24, 0, 201, 24);
jTextField1.setText("bifrostworld.org");
cp.add(jTextField1);
jLabel1.setBounds(16, 112, 212, 48);
jLabel1.setText("IP....");
jLabel1.setFont(new Font("MS Sans Serif", Font.PLAIN, 13));
cp.add(jLabel1);
jButton1.setBounds(80, 48, 81, 41);
jButton1.setText("getIP");
jButton1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
jButton1_ActionPerformed(evt);
}
});
cp.add(jButton1);
// Ende Komponenten
setResizable(false);
setVisible(true);
}
// Anfang Methoden
public void jButton1_ActionPerformed(ActionEvent evt) {
String host = jTextField1.getText();
try{
jLabel1.setText(InetAddress.getByName(host).getHostAddress());
}
catch(Exception e){
System.out.println(e);
}
}
// Ende Methoden
public static void main(String[] args) {
new ip("ip");
}
}