1 2 import java.awt.*; 3 import java.awt.event.*; 4 import javax.swing.*; 5 import java.net.*; 6 7 void jButton1_actionPerformed(ActionEvent e) { 8 try { 9 InetAddress addr = InetAddress.getLocalHost(); 10 11 // Get IP Address 12 byte[] ipAddr = addr.getAddress(); 13 14 // Get hostname 15 this.setTitle("Your PC Name is: "+addr.getHostName()); 16 17 } catch (UnknownHostException e1) { 18 } 19 }