如何将this.frame从AbstractionAction导入到新帧?

时间:2018-03-22 07:52:02

标签: java swing jframe abstraction jmenuitem

我有一个JpopUpMenu将它发送到一个名为" j4a_Lainat"的框架,但它只会引导我进入"不兼容的类型:无法转换为j3_Paaikkuna"。任何帮助,将不胜感激。

编辑:

    private void MENUMousePressed(java.awt.event.MouseEvent evt) {                                  

    ImageIcon PlusIcon = new ImageIcon(getClass().getResource("/Img/Buttons/menu_button_pressed.png"));
    MENU.setIcon(PlusIcon);
    BtnPressed = true;

    JPopupMenu menu;
    JMenuItem m1,m2,m3, m4;

    // Create JButtons

    // Create a JPopupMenu

    menu = new JPopupMenu() {
        @Override
        public void paintComponent(final Graphics g) {
            g.setColor(Color.WHITE);
            g.fillRect(0,0,getWidth(), getHeight());

        }
    };

    // Create JMenuItems

    m1=new JMenuItem(new AbstractAction("Lainat"){

        @Override
        public void actionPerformed(ActionEvent e) {
          j4a_Lainat j4 = new j4a_Lainat(this);         
          j4.setVisible(true);


        }


    }


    );


    m3=new JMenuItem(new AbstractAction("Hyväntekeväisyys"){
        @Override
        public void actionPerformed(ActionEvent e) {
            j4d_Hyvantekevaisyys HT = new j4d_Hyvantekevaisyys(YRNIMI);
            HT.setVisible(true);

        }
    });
    m2=new JMenuItem(new AbstractAction("Tilastot"){
        @Override
        public void actionPerformed(ActionEvent e) {
            try {
                j4e_Tilastot T = new j4e_Tilastot(YRNIMI);
                T.setVisible(true);
            } catch (ClassNotFoundException ex) {
                Logger.getLogger(j3_Paaikkuna.class.getName()).log(Level.SEVERE, null, ex);
            } catch (SQLException ex) {
                Logger.getLogger(j3_Paaikkuna.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
    });
    m4=new JMenuItem("CREDITS");


    menu.add(m1);
    menu.add(m2);
    menu.add(m3);
    menu.add(m4);



    Component b=(Component)evt.getSource();


    Point p=b.getLocationOnScreen();




    menu.show(this,0,0);



    menu.setLocation(p.x-74,p.y+2+b.getHeight());
    System.out.println(send);
    if(send == true){
        System.out.println("Toimii");
         j4a_Lainat l = new j4a_Lainat(this);
         l.setVisible(true);

    }
}
              //j4a_Lainat contructor goes as following

              j4a_Lainat(j3_Paaikkuna aThis){
              initComponents();
              j= aThis;
              }

我称之为j3_Paaikkuna的班级。简单地说,我只想打开一个jpopupmenu,导入j3_Paaikkuna并使用它来调用j3_Paaikkuna中的更新方法。

0 个答案:

没有答案