CrazyEngineers
  • Updating JAVA GUI.

    grsalvi

    Member

    Updated: Oct 23, 2024
    Views: 1.1K
    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 ?
    0
    Replies
Howdy guest!
Dear guest, you must be logged-in to participate on CrazyEngineers. We would love to have you as a member of our community. Consider creating an account or login.
Replies
  • rahul69

    MemberDec 8, 2012

    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!
    Are you sure? This action cannot be undone.
    Cancel
  • grsalvi

    MemberDec 8, 2012

    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.
    Are you sure? This action cannot be undone.
    Cancel
  • rahul69

    MemberDec 9, 2012

    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 😀
    Are you sure? This action cannot be undone.
    Cancel
  • grsalvi

    MemberDec 9, 2012

    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.
    Are you sure? This action cannot be undone.
    Cancel
  • grsalvi

    MemberDec 13, 2012

    Well issue resolved 👍
    It was problem in GUI code.I replaced repaint() method with revalidate(). And it works fine. 😀
    Hope it helps others
    Are you sure? This action cannot be undone.
    Cancel
Home Channels Search Login Register