0

when i execute it the first jframe open then there are many jbuttons, I have only given a work or you can say the actionlistner e.It opens the second jframe that is about the same as the first jframe.But when I press the jbutton I have given the work it does not open any other jframe and it is also not finding the void A.

Here is my code:

import java.awt.*;
import javax.swing.*;
import javax.swing.border.*;
import java.awt.event.*;

public class GUI_window {
    JFrame MF;
    JFrame MFA;
    JFrame ASF;
    JButton ASB = new JButton("THE AREA...");
    JTextField JTFASI = new JTextField("");
    JLabel JLASR = new JLabel("Please type length of 1 side ");
    JButton AS = new JButton("AREA OF A SQUARE");
    JButton AR = new JButton("AREA OF A RECTANGLE");
    JButton AT = new JButton("AREA OF A TRIANGLE");
    JButton LR = new JButton("LENGTH OF A  RECTANGLE WHEN YOU KNOW THE BREADTH AND THE AREA");
    JButton BR = new JButton("BREATH OF A  RECTANGLE WHEN YOU KNOW THE LENGTH AND THE AREA");
    JButton OS = new JButton("LENGTH OF 1 SIDE OF A SQUARE WHEN YOU KNOW AND THE AREA");
    JButton LT = new JButton("LENGTH OF 1 SIDE OF A TRIANGLE WHEN YOU KNOW LENGTH OF 2 SIDES AND THE AREA");
    JButton B = new JButton("BACK");
    JLabel JLA = new JLabel("Please tell what you want to know in the topic 'AREA'");
    JLabel JLl = new JLabel("Please choose want to know what you ");
    JButton F = new JButton("FUNDAMENTAL OPRATIONS");
    JButton TA = new JButton("TABLES");
    JButton T = new JButton("TEMPERATURE");
    JButton E = new JButton("EQUATIONS");
    JButton PAR = new JButton("POWER AND ROOTS");
    JButton A = new JButton("AREA");
    JButton P = new JButton("PERIMETER");
    JButton C = new JButton("CIRCUMFERENCE");
    JButton EXIT = new JButton("EXIT");

    public GUI_window() {
        MmF();

        EXIT.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                System.exit(0);
            }
        });
        A.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                new A();
                MF.setVisible(false);
            }
        });
        P.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                MF.setVisible(false);
            }
        });
        T.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                MF.setVisible(false);
            }
        });
        TA.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                MF.setVisible(false);
            }
        });
        F.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                MF.setVisible(false);
            }
        });
        C.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                MF.setVisible(false);
            }
        });
        E.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                MF.setVisible(false);
            }
        });
        PAR.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                MF.setVisible(false);
            }
        });
    }

    void MmF() {
        MF = new JFrame("MAIN MENU");
        JPanel contentPane = (JPanel) MF.getContentPane();
        contentPane.setLayout(new BorderLayout(8, 8));
        contentPane.setBorder(new EmptyBorder(10, 10, 10, 10));
        contentPane.setLayout(new GridLayout(4, 4));
        JPanel buttonPanel = new JPanel(new GridLayout(4, 4));
        JTextField JTF = new JTextField("");
        contentPane.add(JLl, BorderLayout.NORTH);
        contentPane.add(F);
        contentPane.add(TA);
        contentPane.add(T);
        contentPane.add(E);
        contentPane.add(PAR);
        contentPane.add(P);
        contentPane.add(A);
        contentPane.add(C);
        contentPane.add(EXIT);
        MF.pack();
        MF.setVisible(true);
    }

    void A() {
        AmF();
        B.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                new GUI_window();
                MFA.dispose();
            }
        });
        AS.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                new ASa();
            }
        });
        AT.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {

            }
        });
        AR.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {

            }
        });
        OS.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {

            }
        });
        LR.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {

            }
        });
        LT.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {

            }
        });
        BR.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {

            }
        });
    }

    void AmF() {
        MFA = new JFrame("AREA");
        JPanel contentPane = (JPanel) MFA.getContentPane();
        contentPane.setLayout(new BorderLayout(8, 8));
        contentPane.setBorder(new EmptyBorder(10, 10, 10, 10));
        contentPane.setLayout(new GridLayout(4, 4));
        JPanel buttonPanel = new JPanel(new GridLayout(4, 4));
        contentPane.add(JLA, BorderLayout.NORTH);
        contentPane.add(AS);
        contentPane.add(AR);
        contentPane.add(AT);
        contentPane.add(LR);
        contentPane.add(BR);
        contentPane.add(OS);
        contentPane.add(LT);
        contentPane.add(B);
        MFA.pack();
        MFA.setVisible(true);
    }

    void ASS() {
        AmFas();

        ASB.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                JTFASI.setText(Maths.fforAS());
            }
        });
    }

    void AmFas() {
        ASF = new JFrame("AREA");
        JPanel contentPane = (JPanel) ASF.getContentPane();
        contentPane.setLayout(new BorderLayout(8, 8));
        contentPane.setBorder(new EmptyBorder(10, 10, 10, 10));
        contentPane.setLayout(new GridLayout(4, 4));
        JPanel buttonPanel = new JPanel(new GridLayout(4, 4));
        contentPane.add(JLASR, BorderLayout.NORTH);
        contentPane.add(JTFASI, BorderLayout.NORTH);
        contentPane.add(ASB);
        ASF.pack();
        ASF.setVisible(true);
    }

}
orome
  • 45,163
  • 57
  • 202
  • 418
user3577735
  • 1
  • 1
  • 2

0 Answers0