0

This is where the problem lies:

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {                                         
    try {
        
        ServerSocket ss = new ServerSocket(4999);

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

private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {                                         
    
ss.close(); //this line of code gives the simple cannot find symbol error
    
}  

So yeah, im probably doing something really stupid or i forgot something but yeah tnx in advance.

Xander
  • 1
  • 1
  • The `ServerSocket` object being declared inside a method, it is out of scope from the other one. You may want to declare it at the class level . – Arnaud Oct 01 '20 at 10:19
  • Honestly: if you do not understand such super basic details, you shouldnt be dealing with GUI programming, or sockets or anything. Pick a good book on basic java, and work through that. Otherwise you will run from one problem into the next one. Java alone is complicated enough. Mixing that with Swing GUI stuff, and network communication ... doesnt help. So: focus on the basics, instead of trying to learn everything at the same time. – GhostCat Oct 01 '20 at 10:30
  • @GhostCat the thing is this is something im doing rn, i already have a database setup on a server, and a basic client application and server application, the server applications GUI has 2 buttons, obviously netbeans awt and swing auto generates the code needed for the buttons, but the buttons are private void so obviously its out of scope but physically i cant change the auto genererated code to public...but oh well. – Xander Oct 05 '20 at 11:43

0 Answers0