붓, 그리다
Swing을 이용한 창 결합) JInternalFrame 본문
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 | package j0622; // MDI를 사용 import javax.swing.*; public class JInternalTest extends JFrame { JInternalFrame iframe, iframe2; // 2개의 자식 창 JDesktopPane desktop; // JInternalFrame과 결함하여 화면에 출력 public JInternalTest(String str) { super(str); // 만드는 순서(밖에서 안으로)<->부착(안에서 밖으로) desktop=new JDesktopPane(); //자식 창과 결합하기 위해 // iframe // 생성자 개수 순서 // 1) 창의 제목 2) 창의 크기 조절 유무(논리) 3) closeable 유무(논리) 4) 창의 확대 유무(논리) 5) 창의 아이콘 유무(논리) iframe=new JInternalFrame("내부의 창1",false,false,true,false); // 결합 desktop.add(iframe); // 자식창에 추가로 컴포넌트 부착 iframe.getContentPane().add(new JTextArea("TextArea")); iframe.setBounds(100, 100, 200, 100); iframe.setVisible(true); // iframe2 iframe2=new JInternalFrame("내부의 창2",true,true,true,true); // 결합 desktop.add(iframe2); // 자식창에 추가로 컴포넌트 부착 iframe2.getContentPane().add(new JTextArea("TextArea2")); iframe2.setBounds(100, 250, 200, 100); iframe2.setVisible(true); // 자식창이 결합된 desktop+JFrame에 결합 this.setContentPane(desktop); // ContendPane에 desktop 부착 this.setBounds(200,200,400,400); setVisible(true); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } public static void main(String[] args) { // TODO Auto-generated method stub new JInternalTest("MDI창"); } } | cs |
'JAVA > Swing, Awt' 카테고리의 다른 글
Swing을 이용한 테이블 생성. JTable (0) | 2017.06.23 |
---|
Comments