1 7 8 package org.jdesktop.swing; 9 10 import java.awt.Component ; 11 12 import javax.swing.JFrame ; 13 import javax.swing.JRootPane ; 14 15 19 public class JXFrame extends JFrame { 20 21 public JXFrame() { 22 setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 23 } 24 25 public JXFrame(String title) { 26 super(title); 27 setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 28 } 29 30 33 protected JRootPane createRootPane() { 34 return new JXRootPane(); 35 } 36 37 40 public void setRootPane(JRootPane root) { 41 super.setRootPane(root); 42 } 43 44 47 public void addComponent(Component comp) { 48 JXRootPane root = getRootPaneExt(); 49 if (root != null) { 50 root.addComponent(comp); 51 } 52 } 54 55 58 public void removeComponent(Component comp) { 59 JXRootPane root = getRootPaneExt(); 60 if (root != null) { 61 root.removeComponent(comp); 62 } 63 } 65 66 73 public JXRootPane getRootPaneExt() { 74 if (rootPane instanceof JXRootPane) { 75 return (JXRootPane)rootPane; 76 } 77 return null; 78 } 79 80 83 public void setVisible(boolean visible) { 84 if (visible) { 85 pack(); 86 } 87 super.setVisible(visible); 88 } 89 } 90 91 | Popular Tags |