Java Reference
In-Depth Information
{
Echo frame = new Echo();
frame.setSize(600,400);
frame.setVisible(true);
frame.addWindowListener(
new WindowAdapter()
{
public void windowClosing(WindowEvent e)
{
if (socket != null)
{
try
{
socket.close();
}
catch (IOException ioEx)
{
System.out.println(
"\n* Unable to close link! *\n");
System.exit(1);
}
System.exit(0);
}
}
}
);
}
public Echo()
{
hostPanel = new JPanel();
hostPrompt = new JLabel("Enter host name:");
hostInput = new JTextField(20);
hostInput.addActionListener(this);
hostPanel.add(hostPrompt);
hostPanel.add(hostInput);
add(hostPanel, BorderLayout.NORTH);
entryPanel = new JPanel();
messagePrompt = new JLabel("Enter text:");
lineToSend = new JTextField(15);
//Change fi eld to editable when
// host name entered…
lineToSend.setEditable(false);
Search WWH ::




Custom Search