有什么办法可以从JinternalFrame中调用其他JinternalFrame,但是可以在主Jframe的desktopPane中进行。 [英] is there any way call other JinternalFrame from an JinternalFrame but, in the desktopPane of of main Jframe.

查看:85
本文介绍了有什么办法可以从JinternalFrame中调用其他JinternalFrame,但是可以在主Jframe的desktopPane中进行。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

下面的代码部分1用于从MDI应用程序中的menuItem调用UcakListesi(JinternalFrame),没有问题。

The "code part 1" below is used for calling UcakListesi(JinternalFrame) from menuItem in MDI application without problem.

我想调用相同的UcakListesi(JinternalFrame) )从另一个JinternalFrame使用相同的代码,但是,我收到有关 desktopPane.add(nw);的错误参见代码部分2。无法访问主jframe desktopPane窗体JinternalFrame ..

I would like to call same UcakListesi(JinternalFrame) from another JinternalFrame using same code however, I get error about "desktopPane.add(nw);" line see code part 2. Can't access main jframe desktopPane form JinternalFrame ..

是否可以通过JinternalFrame调用其他JinternalFrame,但是在main的desktopPane中Jframe。

is there any way call other JinternalFrame from an JinternalFrame but, in the desktopPane of of main Jframe.

对不起,我的英语不好。

sorry for my poor english.

致谢,谢谢。

---code part 1---
private void UckListeMenuItemActionPerformed(java.awt.event.ActionEvent evt) {                                                 
    //Uçak listesi penceresi çağrılıyor
    UcakListesi nw = UcakListesi.getInstance();
    nw.pack();
    if (nw.isVisible()) {
    } else {
        desktopPane.add(nw);
        nw.setVisible(true);
    }
    try {
        //açılan internal frame'in max size ile açılması için 
        nw.setMaximum(true);
    } catch (PropertyVetoException ex) {
        Logger.getLogger(AnaUygulama.class.getName()).log(Level.SEVERE, null, ex);
    }
} 
---code part 2---
class PopUpx extends JPopupMenu {
JMenuItem anItem1;
JMenuItem anItem2;
JMenuItem anItem3;
JMenuItem anItem4;
JMenuItem anItem5;
JSeparator anSeparator1; 
JSeparator anSeparator2; 
JSeparator anSeparator3; 
JSeparator anSeparator4; 
JMenu yeni;
ActionListener anListener2;



public  PopUpx(final String x){
    anItem1 = new JMenuItem(x+ " numaralı Uçak için");
    anItem2 = new JMenuItem("Detay Bilgiler");
    anItem3 = new JMenuItem("Arıza İş Emri Aç");
    anItem4 = new JMenuItem("Uçuş Öncesi Servis");
    anItem5 = new JMenuItem("Uçuş Sonrası Servis");
    anSeparator1 = new JSeparator();
    anSeparator2 = new JSeparator();
    anSeparator3 = new JSeparator();
    anSeparator4 = new JSeparator();
    yeni = new JMenu ("Servis İşlemleri");


    add(anItem1);
    anItem1.setEnabled(false);
    add(anSeparator1);
    add(anItem2);
    anItem2.addActionListener(new ActionListener() {

            @Override
        public void actionPerformed(ActionEvent event) {
            System.out.println(x+" nolu uçağın "+anItem2.getText()+" basıldı"); 

            UcakListesi nw = UcakListesi.getInstance();
    nw.pack();

    if (nw.isVisible()) {
    } else {

      //problem is here 
       desktopPane.add(nw);
        nw.setVisible(true);
    }
    try {
        //açılan internal frame'in max size ile açılması için 
        nw.setMaximum(true);
    } catch (PropertyVetoException ex) {
        Logger.getLogger(AnaUygulama.class.getName()).log(Level.SEVERE, null, ex);
    }

        }

    });



    anItem2.setToolTipText(x+ " numaralı Uçağın Detay Bilgilerine ulaşılır...");


    add(anSeparator2);
    add(anItem3);
    add(anSeparator3);
    yeni.add(anItem4);
    add(anSeparator4);
    add(yeni); 
    yeni.add(anItem4);
    yeni.add(anSeparator4);
    yeni.add(anItem5);

 }}


推荐答案

I找到了解决方案。

I found the solution .

用于第一类(MainApplication),其中您的Jframe和JDesktopPane位于下面的位置代码中

for the first class(MainApplication) where your Jframe and JDesktopPane inside place code below

public javax.swing.JDesktopPane getDesktopPane() {
    return desktopPane;
}

然后在像这样的任何JinternalFrame类文件中使用来调用另一个文件(YourJinternalFrame)

then use in any JinternalFrame class file like this to call another one(YourJinternalFrame)

 YourJinternalFrame  nw = YourJinternalFrame.getInstance();
    nw.pack();
    if (nw.isVisible()) {
    } else {
        getDesktopPane().add(nw);
        nw.setVisible(true);
    }
    try {
        nw.setMaximum(true);
    } catch (PropertyVetoException ex) {
        Logger.getLogger(MainApplication.class.getName()).log(Level.SEVERE, null, ex);
    }

仅获取一个名为JinternalFrame的实例
将此代码放在下面在被称为JinternalFrame(YourJinternalFrame)

to get only one instance of called JinternalFrame place this code below in the called JinternalFrame(YourJinternalFrame)

private static YourJinternalFrame myInstance;

public static YourJinternalFrame getInstance() {
    if (myInstance == null) {
        myInstance = new YourJinternalFrame();
    }
    return myInstance;

谢谢:)

这篇关于有什么办法可以从JinternalFrame中调用其他JinternalFrame,但是可以在主Jframe的desktopPane中进行。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆