How to move to various JFrame with handling mousepressed event along action command and get action command. Java swing code:
//this code belongs to home jframe class
mntmPublicSector= new JMenuItem("Public Sector");
    mntmPublicSector.setActionCommand("public");
    mntmPublicSector.addMouseListener(new MouseAdapter() {
        @Override
        public void mousePressed(MouseEvent arg0) { int select=JOptionPane.showConfirmDialog(null,"if already user login","not user Register now",JOptionPane.YES_NO_OPTION);
            if(select==JOptionPane.YES_OPTION)
            {
                new Login_Page().setVisible(true);
                dispose();
            }
            else
            {
                new Student_Register().setVisible(true);
                dispose();
            } }});
mntmStateSector = new JMenuItem("State Sector");
    mntmStateSector.setActionCommand("state");
    mntmStateSector.addMouseListener(new MouseAdapter() {
        @Override
        public void mousePressed(MouseEvent arg0) { int select=JOptionPane.showConfirmDialog(null,"if already user login","not user Register now",JOptionPane.YES_NO_OPTION);
            if(select==JOptionPane.YES_OPTION)
            {
                new Login_Page().setVisible(true);
                dispose();
            }
            else
            {
                new Student_Register().setVisible(true);
                dispose();
            } }});
mntmApptitude = new JMenuItem("Apptitude");
     mntmApptitude.setActionCommand("app");
    mntmApptitude.addMouseListener(new MouseAdapter() {
        @Override
        public void mousePressed(MouseEvent arg0) { int select=JOptionPane.showConfirmDialog(null,"if already user login","not user Register now",JOptionPane.YES_NO_OPTION);
            if(select==JOptionPane.YES_OPTION)
            {
                new Login_Page().setVisible(true);
                dispose();
            }
            else
            {
                new Student_Register().setVisible(true);
                dispose();
            } }});
/*if i click with if i login,it needs to take to respective jframe [--App_Exam_Register_Panel()--or --State_exam_reg()-- or -- Public_exam_Reg()-- ] */
//this code belongs to login jframe class    
JButton btnLogin = new JButton(iim);
Home hm=new Home();
    btnLogin.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {             
            String st=hm.mntmPublicSector.getActionCommand();
            String st1 =hm.mntmStateSector.getActionCommand();
            String aps=hm.mntmApptitude.getActionCommand();
            //String apss=hm.mntmApptitude
            if(st.equals("public"))
            {
                new Public_exam_Reg().setVisible(true);//jframe class
                dispose();
            }     //switch case
            else if(st1.equals("state"))
            {
                new State_exam_reg().setVisible(true);//jframe class
                dispose();
            }
            else if (aps.equals("Apptitude"))
            {
            new App_Exam_Register_Panel().setVisible(true);//jframe class
                dispose();
            }       }       });
 
     
    