if (source  == loginbtn )
            {
               JFrame frame = new JFrame ("AdministratorLogin");
               frame.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE);
               frame.getContentPane().add (new AdministratorLogin());
               frame.pack();
               frame.setLocationRelativeTo(null);
               frame.toFront();
               frame.setVisible (true);
               frame.setResizable(false);

             //the commented dispose code will give me an error of cannot find symbol
            //  dispose();

            }

Recommended Answers

All 2 Replies

Because there is no handle for the member method dispose(), hence there is no idea about which frame is to be disposed. Try:
frame.dispose();

You call dispose() without an object, so that's equivalent to this.dispose();
You didn't show enough code for us to see what kind of Object "this" is, but maybe it's something that doesn't have a dispose() method?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.