-1

JInternalFrame から jpanel ( JDesktopPane にある) へのアクセスを設定したいのですが、それを public に設定しましたが、そのようなテストを行うと「null」が返されません。

JDesktop frameP = new JDesktop();
frameP.jPanel1.setVisible(true); //This is what I want but it doesn't work

System.out.println("Name " + frameP.jPanel1.getName());

したがって、最後の行で null が返されます。これは、彼が JPanel を取得していないことを意味します。

私もそのコードを試します:

 for(int k=0; k<frameP.getContentPane().getComponentCount();k++ ){
             if(frameP.getContentPane().getComponent(k)instanceof  JPanel){
                 JPanel pnl = (JPanel) frameP.getContentPane().getComponent(k);
                 if(pnl.getName().equals("jPanel1")){
                     pnl.setVisible(true);
                 }
                 System.out.println("Nom pnl: " +pnl.getName()); // That gives null too
             }
         } 

何か助けてください。

4

1 に答える 1

0

私はその問題を解決するだけです:

JDesktop.jpnlGauche.setVisible(false);
JDesktop.jpnlHaut.setVisible(false);
于 2013-03-28T14:39:11.967 に答える