2012-09-25 5 views
2

NetBeans 편집기에서 설계된 JFrames (mainFrame.java & child.java) 두 개가 있습니다. 두 번째 JFrame을 첫 번째 프레임에서 자식 창으로 호출하려고합니다. 내가 어떻게 부를 수 있니?Java 하위 창 : Netbeans

+1

가 어떻게이 링크를 체크 아웃 전화하고 싶니? –

+0

mainFrame.java @LewsTherin에서 버튼을 클릭 한 후 child.java를 호출하려고합니다. –

답변

0

을 확인해야 두 번째 프레임에서 호출하십시오.

firstframe fm = new firstframe(); 
fm.setVisible(true); 
0

올바르게 이해하면 내부에 하위/하위 창이있는 기본 창을 갖기를 원합니다. 그렇다면 아래 코드를 확인하십시오.

스크린 샷 : enter image description here

import javax.swing.JDesktopPane; 
import javax.swing.JFrame; 
import javax.swing.SwingUtilities; 
/** 
* Sample demonstrates using JInternalFrame as a child window of a main 
* JFrame window TicTacToe class extends JInternalFrame. 
* @author Kirk 
* 
*/ 
public class BoardBuilder extends JFrame { 

    private TicTacToe board; 
    JDesktopPane desktopPane = new JDesktopPane(); 

    public BoardBuilder() { 
     SwingUtilities.invokeLater(new Runnable() { 
      public void run() { 
       board = new TicTacToe("TicToc Toe", true); 
       board.setSize(250, 250); 
       board.setClosable(true); 
       board.setIconifiable(true); 
       board.setDefaultCloseOperation(TicTacToe.DISPOSE_ON_CLOSE); 
       if (!board.isVisible()) 
        board.setVisible(true); 

       desktopPane.add(board); 
       add(desktopPane); 
      } 
     }); 

    } 

    public static void main(String[] args) { 
     BoardBuilder builderBoard = new BoardBuilder(); 
     builderBoard.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); 
     builderBoard.setSize(640, 480); 
     builderBoard.setVisible(true); 

    } 

    } 

가 자식 창 장소를 버튼 클릭 이벤트에서이 코드 블록을 호출하는 리스너

SwingUtilities.invokeLater(new Runnable() { 
       public void run() { 
       board = new TicTacToe("TicToc Toe", true); 
       board.setSize(250, 250); 
       board.setClosable(true); 
       board.setIconifiable(true); 
       board.setDefaultCloseOperation(TicTacToe.DISPOSE_ON_CLOSE); 
       if (!board.isVisible()) 
        board.setVisible(true); 

       desktopPane.add(board); 
       add(desktopPane); 
      } 
     }); 

미래의 정보의 경우는 docs.oracle-InternalFrames