Firstly, don't extend JFrame
. What you probably need to do is have a field in your class which is a JFrame
.
To provide access to this field from another class, add a getter method to your class and ensure you pass a reference to your class to the other class. E.g.
public class Name {
private final JFrame frame = new JFrame();
public JFrame getFrame() {
return frame;
}
}
Alternatively, decide what other classes may wish to do with your frame and provide specific methods in your class to support this. e.g.
public void makeFrameVisible() {
frame.setVisible(true);
}