0

I am trying to create a program where when the user clicks a JMenuItem (basic) in the frame in class2, it opens the frame in class1. However, when I try to run the code, I keep getting errors about how it can't find the "setVisible" method. I was wondering whether something could give me some pointers. Also, both classes are stored in different java files (but in the same folder).

CLASS 1:

public class CalculatorFrame {
    private JFrame frame;
    public String calc = "";
    public CalculatorFrame() {
        frame = new JFrame("Basic Calculator");
        frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);

CLASS 2:

public class CalculatorFrameA extends CalculatorFrame{
    private JFrame frameA;

    public CalculatorFrameA() {
        frameA = new JFrame("Advanced Calculator");
        frameA.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    ActionListener basicListener = new ActionListener(){ //basic is a JMenuItem
        @Override
        public void actionPerformed(ActionEvent e){
            CalculatorFrame frame = new CalculatorFrame();
            //frame.show();
            frameA.dispose();
            frame.setVisible(true);
        }
    };
assassinweed2
  • 71
  • 1
  • 3
  • 9

0 Answers0