I have been coding for few days with swing, but im getting to a problem …I have functions and variables from different classes that are set in the main class that runs the program and calls the jframe.The problem i have is how do i call the functions in the main class in the jframe code that is set as a new class named as
public class login_sistema extends javax.swing.JFrame
I have tried puting the methods from main as static methods still i cant call the methods this way …If you could help me i would be appreciated …
Static methods are the last thing you should be using. It sounds like you want to have one object call the methods of another object, and to do that the first object must have a valid reference to the second object. This can be achieved by passing it through the first object’s constructor parameter or via a setXXX(…) method.
For instance if the first object creates the second object, it could pass a reference to itself,
thisinto the second object’s parameter. e.g.,The MainClass:
the OtherClass:
For more details on your particular problem, consider telling us more about it and showing code.