Java Reference
In-Depth Information
import javax.swing.*;
import java.net.*;
import java.io.*;
import java.util.*;
public class GetRemoteTime extends JFrame
implements ActionListener
{
private JTextField hostInput;
private JTextArea display;
private JButton timeButton;
private JButton exitButton;
private JPanel buttonPanel;
private static Socket socket = null;
public static void main(String[] args)
{
GetRemoteTime frame = new GetRemoteTime();
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);
}
}
);
}
Search WWH ::




Custom Search