Updating JAVA GUI.

I have this chat server program written in java.

There is one action listener class which monitors actions on connect button (present on GUI JPanel).
please see code below
private class ConnectButtonActionListener implements ActionListener{
        @Override
        public void actionPerformed(ActionEvent ae) {
        h.ui.showBar();
        h.cm.connectToServer();
 
        }
    }
When the user presses the connect button following events happen (please refer code above)
1) h.ui.showBar();

This method is part of class handling GUI of software .It is suppose to display a JProgress bar in south.
This progress bar is just to show that software is in process of connecting to server

2) h.cm.connectToServer();
This method has the code which connects to server .It has other statements but the important one is shown below :
Socket socket=new Socket(ipAddress,portNumber);
My problem :
When i press connect button the Progress bar doesnt appear on screen .After connection is timed out and connection fails ,the bar appears .
While what should happen is explained above.

My Findings till now :
All i could find till now is that there is some problem happening due to
Socket socket=new Socket(ipAddress,portNumber); statement because if i remove this statement the Bar appears the moment user presses Connect Button.

So what you think is going wrong ?

Replies

  • rahul69
    rahul69
    Well, if ur findings are correct, then u must be using the port that is being used by some other application. Port Numbers upto 1024 are well known ports, so try to avoid those unless, u r implementing for specific function (Eg: port 80 for Http), so try port no's > 1024.
    Good Luck!
  • grsalvi
    grsalvi
    rahul69
    Well, if ur findings are correct, then u must be using the port that is being used by some other application. Port Numbers upto 1024 are well known ports, so try to avoid those unless, u r implementing for specific function (Eg: port 80 for Http), so try port no's > 1024.
    Good Luck!
    Off course i am using port greater than 1024,its 5000. Please read post properly i have no connection issue.Its about GUI.Just read it properly.
  • rahul69
    rahul69
    grsalvi
    Off course i am using port greater than 1024,its 5000. Please read post properly i have no connection issue.Its about GUI.Just read it properly.
    Actually I read the post properly and u have not mentioned the value of port number in ur first post. Generally the smallest mistakes are the reasons for greatest blunders and I mentioned one such thing u do which could have caused this problem, so
    it is better to have patience if u need help😉.
    Could u post the code snippets for those two functions ie. showbar() and connecttoserver(), so that I could check and give u precise response rather than mere possibilites 😀
  • grsalvi
    grsalvi
    rahul69
    Actually I read the post properly and u have not mentioned the port number in ur post. Generally the smallest mistakes are the reasons for greatest blunders and I mentioned one such thing u do which could have caused this problem, so
    it is better to have patience if u need help😉.
    Could u post the code snippets for those two functions ie. showbar() and connecttoserver(), so that I could check and give u precise response rather than mere possibilites 😀
    Buddy i am really very patient and all suggestions are welcomed.
    If i have not mentioned port number ,its because its actually an static variable with initialized value 5000.Also ipAddress is not mentioned ,does that also confuse you ?

    How in JAVA the port number shall affect working of JAVA GUI?
    If you want to help me please be relevant ,don't go on telling common pit falls.
  • grsalvi
    grsalvi
    Well issue resolved 👍
    It was problem in GUI code.I replaced repaint() method with revalidate(). And it works fine. 😀
    Hope it helps others

You are reading an archived discussion.

Related Posts

A little girl had been shopping with her Mum in Woolies. She must have been 6 years old, this beautiful red haired, freckle faced image of innocence. It was pouring...
Hi, Can anyone tell me the difference between briefcase and the folder in terms of their pros and cons. The parameters that I would like to focus are the effectiveness...
I want to pursue MS. I have one backlog but due to personal problem didn't attended it for second attempt. Repetition of subject thrice; is it considered as three backlogs...
,sirs and madams, im on my topic proposal for my final year, my idea is a line following robot used in hospitals for delivering supplies per room, like food, medicines...
Is it one's talent or his/her attitude that makes them successful? That's the topic of the talk I'm going to attend in a short while. I thought of starting this...