error ... when calling a class
hello
i am making a chat server program and i have made a connection dialog box which allow to make connection to the program now i want that when we click on ok button of connection dialog box , the program start so i call the class of client on the click event of ok button . please take a look below . the calling of class is mentioned in red color. please help me out if there is any mistake in the program.
import java.net.*;
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import javax.swing.*;
import javax.swing.event.*;
public class Connect extends JFrame implements MouseListener{
Button buttonC = new Button("CONNECT");
TextField textField = new TextField("",0);
Button button = new Button("CANCEL");
Label label = new Label("Enetr your login name to connect to Induljin Chat",Label.CENTER);
JPanel border =new JPanel(new BorderLayout(5,5));
static final int port = 1666;
static InetAddress host;
public Connect(){
super("CONNECT DIALOG");
this.setResizable(true);
this.setDefaultCloseOperation(WindowConstants.HIDE _ON_CLOSE);
this.addMouseListener(this);
buttonC.addMouseListener(this);
button.addMouseListener(this);
//this.addWindowFocusListener(this);
this.setBackground(Color.lightGray);
buttonC.setBackground(Color.cyan);
buttonC.setForeground(Color.blue);
//textField.setEchoChar('*');
button.setBackground(Color.cyan);
button.setForeground(Color.blue);
label.setForeground(Color.blue);
border.setBackground(null);
border.setForeground(null);
border.setCursor(Cursor.getPredefinedCursor(Cursor .DEFAULT_CURSOR));
border.setFont(null);
border.add("South",textField);
border.add("West",button);
border.add("Center",label);
border.add("East",buttonC);
getContentPane().add("Center",border);
//pack();
}
//public void (WindowEvent evt){}
//public void windowLostFocus(WindowEvent evt){}
public void mouseClicked(MouseEvent evt)
{
if(evt.getSource()==buttonC){
try{
host = InetAddress.getLocalHost();
ChatClient client = new ChatClient(host,port);
client.start();
}
catch(Exception e){
e.printStackTrace();}
}
else
if(evt.getSource()==button){
this.setVisible(false);
}
}
public void mouseEntered(MouseEvent evt){}
public void mouseExited(MouseEvent evt){}
public void mousePressed(MouseEvent evt){}
public void mouseReleased(MouseEvent evt){}
}
HumaMunir
__________________
HumaMunir
|