This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 165181 - netbeans 6.1 Client socket issue
Summary: netbeans 6.1 Client socket issue
Status: RESOLVED DUPLICATE of bug 134745
Alias: None
Product: guibuilder
Classification: Unclassified
Component: Code (show other bugs)
Version: 6.x
Hardware: PC Windows XP
: P3 blocker (vote)
Assignee: issues@ide
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-05-14 15:18 UTC by malas7malas
Modified: 2009-07-15 18:28 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description malas7malas 2009-05-14 15:18:15 UTC
I have an issue with my client socket. 
For various tests I'm using port peeker as a server and listening on port 90.
When I created GUI my self without netbeans designer I had no problem establish connection to port peeker, but if I 
use netbeans designer to draw a GUI I can't establish connection, it just freezes for 1 min. I tried debug and it 
always stuck on the Socket socket = new Socket("10.19.0.175", 90) line, then goes into catch (IOException ex).
This problem occurs when I'm using domain environment in a work place, I tried at home and I had no problem, both ways 
worked fine.  


For tests I’m using basic connection.

Try{

Socket socket = new Socket("10.19.0.175", 90);



    output =
            new PrintWriter(socket.getOutputStream(), true);

    in =
         new BufferedReader(new InputStreamReader(socket.getInputStream()));

  }
Catch(IOException e){
}
Comment 1 Jiri Prox 2009-05-14 15:26:06 UTC
Can you please provide more code?
Comment 2 malas7malas 2009-05-14 17:27:19 UTC
Thank you very much for a quick respond.

 

I have attached three files of my netbeans project.

 

Problem occurs in action listener below and file name ClientView

 

private void connectButtonActionPerformed(java.awt.event.ActionEvent evt) { 

 

 

 

 when I click a button it goes as fare as

 

socket = new Socket(ip, port);

 

In a Debug mode I checked local variables and was fine, I  even tried manually set ip address and port number socket = 
new Socket(“10.19.0.175”, 90);, but didn’t worked as well.

package clientapplication;

import java.util.logging.Level;
import java.util.logging.Logger;
import org.jdesktop.application.Action;
import org.jdesktop.application.ResourceMap;
import org.jdesktop.application.SingleFrameApplication;
import org.jdesktop.application.FrameView;
import org.jdesktop.application.TaskMonitor;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.IOException;
import java.net.Socket;
import javax.swing.Timer;
import javax.swing.Icon;
import javax.swing.JDialog;
import javax.swing.JFrame;
import java.io.*;
import java.net.*;
import java.awt.*;
import java.awt.event.*;
import java.net.ServerSocket;
import java.util.Date;

/**
 * The application's main frame.
 */
public class ClientView extends FrameView {

    public ClientView(SingleFrameApplication app) {

        super(app);

        initComponents();

        // status bar initialization - message timeout, idle icon and busy animation, etc
        ResourceMap resourceMap = getResourceMap();
        int messageTimeout = resourceMap.getInteger("StatusBar.messageTimeout");
        messageTimer = new Timer(messageTimeout, new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                statusMessageLabel.setText("");
            }
        });
        messageTimer.setRepeats(false);
        int busyAnimationRate = resourceMap.getInteger("StatusBar.busyAnimationRate");
        for (int i = 0; i < busyIcons.length; i++) {
            busyIcons[i] = resourceMap.getIcon("StatusBar.busyIcons[" + i + "]");
        }
        busyIconTimer = new Timer(busyAnimationRate, new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                busyIconIndex = (busyIconIndex + 1) % busyIcons.length;
                statusAnimationLabel.setIcon(busyIcons[busyIconIndex]);
            }
        });
        idleIcon = resourceMap.getIcon("StatusBar.idleIcon");
        statusAnimationLabel.setIcon(idleIcon);
    //    progressBar.setVisible(false);

        // connecting action tasks to status bar via TaskMonitor
        TaskMonitor taskMonitor = new TaskMonitor(getApplication().getContext());
        taskMonitor.addPropertyChangeListener(new java.beans.PropertyChangeListener() {
            public void propertyChange(java.beans.PropertyChangeEvent evt) {
                String propertyName = evt.getPropertyName();
                if ("started".equals(propertyName)) {
                    if (!busyIconTimer.isRunning()) {
                        statusAnimationLabel.setIcon(busyIcons[0]);
                        busyIconIndex = 0;
                        busyIconTimer.start();
                    }
   //                 progressBar.setVisible(true);
    //                progressBar.setIndeterminate(true);
                } else if ("done".equals(propertyName)) {
                    busyIconTimer.stop();
                    statusAnimationLabel.setIcon(idleIcon);
     //               progressBar.setVisible(false);
     //               progressBar.setValue(0);
                } else if ("message".equals(propertyName)) {
                    String text = (String)(evt.getNewValue());
                    statusMessageLabel.setText((text == null) ? "" : text);
                    messageTimer.restart();
                } else if ("progress".equals(propertyName)) {
                    int value = (Integer)(evt.getNewValue());
    //                progressBar.setVisible(true);
    //                progressBar.setIndeterminate(false);
     //               progressBar.setValue(value);
                }
            }
        });
    }

    @Action
    public void showAboutBox() {
        if (aboutBox == null) {
            JFrame mainFrame = ClientApplication.getApplication().getMainFrame();
            aboutBox = new ClientAboutBox(mainFrame);
            aboutBox.setLocationRelativeTo(mainFrame);
        }
        ClientApplication.getApplication().show(aboutBox);
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">                          
    private void initComponents() {

        mainPanel = new javax.swing.JPanel();
        connectButton = new java.awt.Button();
        textArea1 = new java.awt.TextArea();
        messageField = new java.awt.TextField();
        submitButton = new java.awt.Button();
        Message = new java.awt.Label();
        label2 = new java.awt.Label();
        ipField = new java.awt.TextField();
        portField = new java.awt.TextField();
        label3 = new java.awt.Label();
        disconectButton = new java.awt.Button();
        imeiField = new java.awt.TextField();
        label1 = new java.awt.Label();
        menuBar = new javax.swing.JMenuBar();
        javax.swing.JMenu fileMenu = new javax.swing.JMenu();
        javax.swing.JMenuItem exitMenuItem = new javax.swing.JMenuItem();
        javax.swing.JMenu helpMenu = new javax.swing.JMenu();
        javax.swing.JMenuItem aboutMenuItem = new javax.swing.JMenuItem();
        statusPanel = new javax.swing.JPanel();
        javax.swing.JSeparator statusPanelSeparator = new javax.swing.JSeparator();
        statusMessageLabel = new javax.swing.JLabel();
        statusAnimationLabel = new javax.swing.JLabel();

        mainPanel.setMaximumSize(new java.awt.Dimension(883, 453));
        mainPanel.setMinimumSize(new java.awt.Dimension(883, 453));
        mainPanel.setName("mainPanel"); // NOI18N

        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance
(clientapplication.ClientApplication.class).getContext().getResourceMap(ClientView.class);
        connectButton.setLabel(resourceMap.getString("ConButton.label")); // NOI18N
        connectButton.setName("ConButton"); // NOI18N
        connectButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                connectButtonActionPerformed(evt);
            }
        });

        textArea1.setName("textArea1"); // NOI18N

        messageField.setName("malas"); // NOI18N
        messageField.setText(resourceMap.getString("malas.text")); // NOI18N
        messageField.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                messageFieldActionPerformed(evt);
            }
        });

        submitButton.setEnabled(false);
        submitButton.setLabel(resourceMap.getString("subButton.label")); // NOI18N
        submitButton.setName("subButton"); // NOI18N
        submitButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                submitButtonActionPerformed(evt);
            }
        });

        Message.setName("Message"); // NOI18N
        Message.setText(resourceMap.getString("Message.text")); // NOI18N

        label2.setFont(resourceMap.getFont("label2.font")); // NOI18N
        label2.setForeground(resourceMap.getColor("label2.foreground")); // NOI18N
        label2.setName("label2"); // NOI18N
        label2.setText(resourceMap.getString("label2.text")); // NOI18N

        ipField.setName("ipField"); // NOI18N
        ipField.setText(resourceMap.getString("ipField.text")); // NOI18N

        portField.setName("portField"); // NOI18N
        portField.setText(resourceMap.getString("portField.text")); // NOI18N

        label3.setFont(resourceMap.getFont("label3.font")); // NOI18N
        label3.setName("label3"); // NOI18N
        label3.setText(resourceMap.getString("label3.text")); // NOI18N

        disconectButton.setEnabled(false);
        disconectButton.setLabel(resourceMap.getString("disconectButton.label")); // NOI18N
        disconectButton.setName("disconectButton"); // NOI18N
        disconectButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                disconectButtonActionPerformed(evt);
            }
        });

        imeiField.setName("imeiField"); // NOI18N
        imeiField.setText(resourceMap.getString("imeiField.text")); // NOI18N
        imeiField.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                imeiFieldActionPerformed(evt);
            }
        });

        label1.setFont(resourceMap.getFont("label1.font")); // NOI18N
        label1.setName("label1"); // NOI18N
        label1.setText(resourceMap.getString("label1.text")); // NOI18N

        javax.swing.GroupLayout mainPanelLayout = new javax.swing.GroupLayout(mainPanel);
        mainPanel.setLayout(mainPanelLayout);
        mainPanelLayout.setHorizontalGroup(
            mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(mainPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(mainPanelLayout.createSequentialGroup()
                        .addComponent(textArea1, javax.swing.GroupLayout.DEFAULT_SIZE, 863, Short.MAX_VALUE)
                        .addContainerGap())
                    .addGroup(mainPanelLayout.createSequentialGroup()
                        .addComponent(Message, javax.swing.GroupLayout.PREFERRED_SIZE, 
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(25, 25, 25)
                        .addComponent(messageField, javax.swing.GroupLayout.PREFERRED_SIZE, 431, 
javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 162, Short.MAX_VALUE)
                        .addComponent(submitButton, javax.swing.GroupLayout.PREFERRED_SIZE, 143, 
javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(57, 57, 57))
                    .addGroup(mainPanelLayout.createSequentialGroup()
                        .addGap(13, 13, 13)
                        .addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addGroup(mainPanelLayout.createSequentialGroup()
                                .addComponent(label2, javax.swing.GroupLayout.PREFERRED_SIZE, 
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(23, 23, 23))
                            .addGroup(mainPanelLayout.createSequentialGroup()
                                .addComponent(label1, javax.swing.GroupLayout.PREFERRED_SIZE, 
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)))
                        .addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(mainPanelLayout.createSequentialGroup()
                                .addComponent(ipField, javax.swing.GroupLayout.PREFERRED_SIZE, 136, 
javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(42, 42, 42)
                                .addComponent(label3, javax.swing.GroupLayout.PREFERRED_SIZE, 
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(portField, javax.swing.GroupLayout.PREFERRED_SIZE, 44, 
javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(50, 50, 50)
                                .addComponent(connectButton, javax.swing.GroupLayout.PREFERRED_SIZE, 125, 
javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 33, 
Short.MAX_VALUE)
                                .addComponent(disconectButton, javax.swing.GroupLayout.PREFERRED_SIZE, 136, 
javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(40, 40, 40))
                            .addGroup(mainPanelLayout.createSequentialGroup()
                                .addComponent(imeiField, javax.swing.GroupLayout.PREFERRED_SIZE, 409, 
javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addContainerGap())))))
        );
        mainPanelLayout.setVerticalGroup(
            mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, mainPanelLayout.createSequentialGroup()
                .addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(Message, javax.swing.GroupLayout.PREFERRED_SIZE, 
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(submitButton, javax.swing.GroupLayout.PREFERRED_SIZE, 
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(messageField, javax.swing.GroupLayout.PREFERRED_SIZE, 
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(23, 23, 23)
                .addComponent(textArea1, javax.swing.GroupLayout.PREFERRED_SIZE, 280, 
javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addComponent(disconectButton, javax.swing.GroupLayout.PREFERRED_SIZE, 
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(connectButton, javax.swing.GroupLayout.PREFERRED_SIZE, 
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(portField, javax.swing.GroupLayout.Alignment.TRAILING, 
javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(label3, javax.swing.GroupLayout.Alignment.TRAILING, 
javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(ipField, javax.swing.GroupLayout.Alignment.TRAILING, 
javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(label2, javax.swing.GroupLayout.PREFERRED_SIZE, 
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(19, 19, 19)
                .addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(imeiField, javax.swing.GroupLayout.PREFERRED_SIZE, 
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(label1, javax.swing.GroupLayout.PREFERRED_SIZE, 
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(21, 21, 21))
        );

        menuBar.setEnabled(false);
        menuBar.setName("menuBar"); // NOI18N

        fileMenu.setText(resourceMap.getString("fileMenu.text")); // NOI18N
        fileMenu.setName("fileMenu"); // NOI18N

        javax.swing.ActionMap actionMap = org.jdesktop.application.Application.getInstance
(clientapplication.ClientApplication.class).getContext().getActionMap(ClientView.class, this);
        exitMenuItem.setAction(actionMap.get("quit")); // NOI18N
        exitMenuItem.setName("exitMenuItem"); // NOI18N
        fileMenu.add(exitMenuItem);

        menuBar.add(fileMenu);

        helpMenu.setText(resourceMap.getString("helpMenu.text")); // NOI18N
        helpMenu.setName("helpMenu"); // NOI18N

        aboutMenuItem.setAction(actionMap.get("showAboutBox")); // NOI18N
        aboutMenuItem.setName("aboutMenuItem"); // NOI18N
        helpMenu.add(aboutMenuItem);

        menuBar.add(helpMenu);

        statusPanel.setAutoscrolls(true);
        statusPanel.setName("statusPanel"); // NOI18N

        statusPanelSeparator.setName("statusPanelSeparator"); // NOI18N

        statusMessageLabel.setName("statusMessageLabel"); // NOI18N

        statusAnimationLabel.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
        statusAnimationLabel.setName("statusAnimationLabel"); // NOI18N

        javax.swing.GroupLayout statusPanelLayout = new javax.swing.GroupLayout(statusPanel);
        statusPanel.setLayout(statusPanelLayout);
        statusPanelLayout.setHorizontalGroup(
            statusPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(statusPanelSeparator, javax.swing.GroupLayout.DEFAULT_SIZE, 883, Short.MAX_VALUE)
            .addGroup(statusPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(statusMessageLabel)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 863, Short.MAX_VALUE)
                .addComponent(statusAnimationLabel)
                .addContainerGap())
        );
        statusPanelLayout.setVerticalGroup(
            statusPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(statusPanelLayout.createSequentialGroup()
                .addComponent(statusPanelSeparator, javax.swing.GroupLayout.PREFERRED_SIZE, 2, 
javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(statusPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(statusMessageLabel)
                    .addComponent(statusAnimationLabel))
                .addGap(3, 3, 3))
        );

        setComponent(mainPanel);
        setMenuBar(menuBar);
        setStatusBar(statusPanel);
    }// </editor-fold>                        

    private void messageFieldActionPerformed(java.awt.event.ActionEvent evt) 
{                                             
        // TODO add your handling code here:
}                                            

    private void submitButtonActionPerformed(java.awt.event.ActionEvent evt) 
{                                             

       

        message = messageField.getText();

        beforeSent = false;

        messageField.setText("");

        beforeSent = socket.isClosed();


        if (beforeSent == false){

            output.println(message);
        }
        else{
            textArea1.append(" Error code 2, Message failed to send" + '\n');
        }

       finalCheck = false;

         finalCheck = socket.isClosed();

if (finalCheck == true){

       textArea1.append((" Disconnected from server socket " + '\n'));
       
       connectButton.setEnabled(true);
      disconectButton.setEnabled(false);
      submitButton.setEnabled(false);

}                                            
    }
    private void connectButtonActionPerformed(java.awt.event.ActionEvent evt) 
{                                              


      //Takes ipaddress port number and message
      ip = ipField.getText();
     port = Integer.parseInt(portField.getText());
      IMEI = imeiField.getText();

      //checks if port valid
     if (port <= 0 || port >= 65536){

        textArea1.append(" An error occured connecting check if this is valid IP address "
                                                                 + ip + " and port " + port + '\n');
    }

     else{
       try{
        
     

            socket = new Socket(ip, port);


       output =
                new PrintWriter(socket.getOutputStream(), true);

          connection = false;

              in =
                  new BufferedReader(new InputStreamReader(socket.getInputStream()));

              //checks if connected
             connection = socket.isClosed();



  if (connection == false){

      connectButton.setEnabled(false);
      disconectButton.setEnabled(true);
      submitButton.setEnabled(true);

      readFromServer conn = new readFromServer(textArea1, socket);

      Thread thread = new Thread(conn);

      thread.start();

       textArea1.append(" Connected to " + socket.getRemoteSocketAddress() +  " Time  " + new Date() + '\n');
       
       while((fromServer = in.readLine()) != null){
           
           textArea1.append(fromServer);
       }

  
      try {
         output.println(IMEI);
     } catch (Exception e) {

          textArea1.append ( " First message send failed");
      }


         

            
       }
 else{
                  textArea1.append(" Disconnected from server " + '\n');

                  connectButton.setEnabled(true);
      disconectButton.setEnabled(false);
      submitButton.setEnabled(false);

  }
        }
  
        
        catch(UnknownHostException e){
              textArea1.append(e.toString());
        }
         catch(SocketTimeoutException e){

       textArea1.append(e.toString());
   }
       catch (IOException e){
            textArea1.append( " Error code 1: Remote server socket is down " + '\n');

              connectButton.setEnabled(true);
      disconectButton.setEnabled(false);
      submitButton.setEnabled(false);

       }
  
       
        
          firstime = true;

            finalCheck = false;

             finalCheck = socket.isClosed();

if (finalCheck == true){

       textArea1.append((" Disconected from server " + '\n'));

       connectButton.setEnabled(true);
      disconectButton.setEnabled(false);
      submitButton.setEnabled(false);

 
}                                             
     }
    }

    private void disconectButtonActionPerformed(java.awt.event.ActionEvent evt) 
{                                                

   
      
        try {
            socket.close();
            output.close();


        } catch (IOException ex) {
            Logger.getLogger(ClientView.class.getName()).log(Level.SEVERE, null, ex);
        }

         finalCheck = false;

              finalCheck = socket.isClosed();

if (finalCheck == true){
textArea1.append("Disconnected from server" + new Date() + '\n');

 connectButton.setEnabled(true);
      disconectButton.setEnabled(false);
      submitButton.setEnabled(false);
}
else if (finalCheck == false){

    textArea1.append("Error code 4 An Error accured disconnecting from server socket" + '\n');

     connectButton.setEnabled(false);
      disconectButton.setEnabled(true);
      submitButton.setEnabled(true);
}
}                                               

    private void imeiFieldActionPerformed(java.awt.event.ActionEvent evt) {                                          
        // TODO add your handling code here:
}                                         

    // Variables declaration - do not modify                     
    private java.awt.Label Message;
    private java.awt.Button connectButton;
    private java.awt.Button disconectButton;
    private java.awt.TextField imeiField;
    private java.awt.TextField ipField;
    private java.awt.Label label1;
    private java.awt.Label label2;
    private java.awt.Label label3;
    private javax.swing.JPanel mainPanel;
    private javax.swing.JMenuBar menuBar;
    private java.awt.TextField messageField;
    private java.awt.TextField portField;
    private javax.swing.JLabel statusAnimationLabel;
    private javax.swing.JLabel statusMessageLabel;
    private javax.swing.JPanel statusPanel;
    private java.awt.Button submitButton;
    private java.awt.TextArea textArea1;
    // End of variables declaration                   

    private final Timer messageTimer;
    private final Timer busyIconTimer;
    private final Icon idleIcon;
    private final Icon[] busyIcons = new Icon[15];
    private int busyIconIndex = 0;
    private String ip, message, fromServer, IMEI, localip, localport;
    private int port;
    private JDialog aboutBox;
    private PrintWriter output = null;
    private BufferedReader in = null;
    boolean firstime = false;
    boolean beforeSent = false;
    boolean connection = false;
    boolean finalCheck = false;
    public Socket socket = null;
}
 
Comment 3 Tomas Pavek 2009-07-15 18:28:45 UTC
Since you use Swing Application Framework for the GUI created in NetBeans, I guess you face the known issue caused by
Swing App Framework setting the java.net.useSystemProxies system
property. See http://www.netbeans.org/issues/show_bug.cgi?id=134745#desc16 for a workaround. Let us know in case it does
not help.


*** This issue has been marked as a duplicate of 134745 ***