Ajuda: Abrir somente uma unica vez o JInternalFrame + Reabrir JInternalFrame
2 respostas
digoveneno
Boa noite, sou iniciante em Java e estou desenvolvendo um programa onde contem um JDesktopPanel que ali posso trabalhar com JInternalFrame, certo… O meu problema eh o seguinte quando realizo a abertura de um JInternalFrame eu nao consigo abrir o mesmo JInternalFrame, porem se eu fechar o mesmo e tentar abrir novamente isso nao funciona. Já fiz diversas tentativas e nao houveram sucesso.
Se puderem dar uma mão ficaria muito grato. Obrigado
viu por acaso vc esta usando o metodo dispose() para fechar a internalframe?
vc esta programando na mão ou vc ta usando o arrasta-solta?
falo
S
silviogs
Olá amigo
coloque isso no frame principal:
staticFrameSequenciaframeSequencia;publicFramePrincipal(){addMenuListener(newMenuListener(){publicvoidmenuSelected(MenuEvente){buildChildMenus();}publicvoidmenuDeselected(MenuEventarg0){thrownewUnsupportedOperationException("Not supported yet.");}publicvoidmenuCanceled(MenuEventarg0){thrownewUnsupportedOperationException("Not supported yet.");}});}privatevoidaddMenuListener(MenuListenermenuListener){buildChildMenus();}classChildMenuItemextendsJCheckBoxMenuItem{privateJInternalFrameframe;publicChildMenuItem(JInternalFrameframe){super(frame.getTitle());this.frame=frame;}publicJInternalFramegetFrame(){returnframe;}}privatevoidbuildChildMenus(){inti;ChildMenuItemmenu;JInternalFrame[]array=desktop.getAllFrames();for(i=0;i<array.length;i++){menu=newChildMenuItem(array[i]);menu.setState(i==0);menu.addActionListener(newActionListener(){publicvoidactionPerformed(ActionEventae){JInternalFrameframe=((ChildMenuItem)ae.getSource()).getFrame();frame.moveToFront();try{frame.setSelected(true);frame.repaint();}catch(PropertyVetoExceptione){e.printStackTrace();}}});menu.setIcon(array[i].getFrameIcon());menujanela.add(menu);//add(menu);}}protectedvoidcreateFrameSequencia()throwsPropertyVetoException,Exception{if(frameSequencia==null){frameSequencia=newFrameSequencia();frameSequencia.setVisible(true);desktop.add(frameSequencia);frameSequencia.pack();desktop.getDesktopManager().maximizeFrame(frameSequencia);}else{frameSequencia.setVisible(true);//necessary as of 1.3}try{frameSequencia.setSelected(true);}catch(java.beans.PropertyVetoExceptione){}}