I am messing around making a small Server-Client application to send out popups to workstations on our network. I created the GUI in NetBeans, and I am not sure how to complete this in the proper fashion. I find myself making programs work, not really knowing if this is how the rest of the "real programmers" in the world would do it the same way.
So, anyone that uses Netbeans knows that the GUI layout is placed in a method
CODE
private void initComponents()
which is located under the No arg constructor of the GUI that you are making. So do I place my Socket constructors in the No arg constructor of my GUI, like so
CODE
try
{
//Create server socket//
ServerSocket serverSocket = new ServerSocket(8001);
jta.append("Server started at " + new Date() + "\n");
//Listen for connection request//
Socket socket = serverSocket.accept();
//Create data input and output streams//
DataInputStream inputFromClient = new DataInputStream(
socket.getInputStream());
DataOutputStream outputToClient = new DataOutputStream(
socket.getOutputStream());
}
catch(IOException ex)
{
errorLabel.setText("Error connection to clients!");
}
This is how I thought it was supposed to be done, since the jta.append() and errorLabel.setText() will both tell my I am trying to refrence a non-static variable if I was to put this in "main". But, by putting them under my GUI constructor, it does not even recognize jta(JTextArea) and errorLabel(JLabel) as existing. What is the proper way of doing this?
Thanks for any help guys.
This post has been edited by blake11: 9 May, 2008 - 04:52 AM