Q:

Running Methods for Objects in Another Class in Java

I have an ActionListener in a class extending JFrame. On button click I need to set the visibility of JFrame extended objects created in a Main class. In this example, clicking the button will make the existing object with that button become non-visible and it will make another JFrame object become visible.
The ActionListener is inside of one JFrame class, the object is created inside the Main class. How can I run the method of that specific object within the Main class from the ActionListener inside the JFrame class?
I already have a setVisibility method, but am unclear on how I can direct the ActionListener to run this method on an object that exists inside another class.
In Main Class:
Object1 jFrameObj1 = new Object1();

Object2 jFrameObj2 = new Object2();

In Object1 Class (inside action listener):
if(event.getSource() == button){

  jFrameObj1.setVisible(false);

  jFrameObj2.setVisible(true);

}

A:

First of all, you should respect Java naming conventions, and choose much better names for your classes and variables. When you want to call a method on an object, you need a reference to this object. So the main method simply needs to pass a reference to the second frame to the first frame:
Object2 frame2 = new Object2();
Object1 frame1 = new Object1(frame2);

Then in the Object1 class:
private Object2 frameToDisplayWhenButtonIsClicked;

public Object2(frameToDisplayWhenButtonIsClicked) {
    this.frameToDisplayWhenButtonIsClicked;
}

...

public void actionPerformed(ActionEvent e) {
    setVisible(false);
    frameToDisplayWhenButtonIsClicked.setVisible(true);
}

