Java Reference
In-Depth Information
{
private JLabel prompt;
private JTextField hostInput;
private JTextArea report;
private JButton seekButton, exitButton;
private JPanel hostPanel, buttonPanel;
private static Socket socket = null;
public static void main(String[] args)
{
PortScanner frame = new PortScanner();
frame.setSize(400,300);
frame.setVisible(true);
frame.addWindowListener(
new WindowAdapter()
{
public void windowClosing(
WindowEvent event)
{
//Check whether a socket is open…
if (socket != null)
{
try
{
socket.close();
}
catch (IOException ioEx)
{
System.out.println(
"\nUnable to close link!\n");
System.exit(1);
}
}
System.exit(0);
}
}
);
}
public PortScanner()
{
hostPanel = new JPanel();
prompt = new JLabel("Host name: ");
hostInput = new JTextField("ivy.shu.ac.uk", 25);
hostPanel.add(prompt);
Search WWH ::




Custom Search