1 7 package javax.swing; 8 9 import java.awt.*; 10 import java.awt.event.*; 11 import java.beans.PropertyChangeListener ; 12 import java.util.Locale ; 13 import java.util.Vector ; 14 import java.io.Serializable ; 15 16 import javax.accessibility.*; 17 18 70 public class JWindow extends Window implements Accessible, RootPaneContainer 71 { 72 81 protected JRootPane rootPane; 82 83 92 protected boolean rootPaneCheckingEnabled = false; 93 94 107 public JWindow() { 108 this((Frame)null); 109 } 110 111 133 public JWindow(GraphicsConfiguration gc) { 134 this(null, gc); 135 super.setFocusableWindowState(false); 136 } 137 138 155 public JWindow(Frame owner) { 156 super(owner == null? SwingUtilities.getSharedOwnerFrame() : owner); 157 if (owner == null) { 158 WindowListener ownerShutdownListener = 159 (WindowListener)SwingUtilities.getSharedOwnerFrameShutdownListener(); 160 addWindowListener(ownerShutdownListener); 161 } 162 windowInit(); 163 } 164 165 181 public JWindow(Window owner) { 182 super(owner == null ? (Window)SwingUtilities.getSharedOwnerFrame() : 183 owner); 184 if (owner == null) { 185 WindowListener ownerShutdownListener = 186 (WindowListener)SwingUtilities.getSharedOwnerFrameShutdownListener(); 187 addWindowListener(ownerShutdownListener); 188 } 189 windowInit(); 190 } 191 192 219 public JWindow(Window owner, GraphicsConfiguration gc) { 220 super(owner == null ? (Window)SwingUtilities.getSharedOwnerFrame() : 221 owner, gc); 222 if (owner == null) { 223 WindowListener ownerShutdownListener = 224 (WindowListener)SwingUtilities.getSharedOwnerFrameShutdownListener(); 225 addWindowListener(ownerShutdownListener); 226 } 227 windowInit(); 228 } 229 230 233 protected void windowInit() { 234 setLocale( JComponent.getDefaultLocale() ); 235 setRootPane(createRootPane()); 236 setRootPaneCheckingEnabled(true); 237 sun.awt.SunToolkit.checkAndSetPolicy(this, true); 238 } 239 240 244 protected JRootPane createRootPane() { 245 JRootPane rp = new JRootPane (); 246 rp.setOpaque(true); 251 return rp; 252 } 253 254 266 protected boolean isRootPaneCheckingEnabled() { 267 return rootPaneCheckingEnabled; 268 } 269 270 271 277 public void update(Graphics g) { 278 paint(g); 279 } 280 281 297 protected void setRootPaneCheckingEnabled(boolean enabled) { 298 rootPaneCheckingEnabled = enabled; 299 } 300 301 302 321 protected void addImpl(Component comp, Object constraints, int index) 322 { 323 if(isRootPaneCheckingEnabled()) { 324 getContentPane().add(comp, constraints, index); 325 } 326 else { 327 super.addImpl(comp, constraints, index); 328 } 329 } 330 331 343 public void remove(Component comp) { 344 if (comp == rootPane) { 345 super.remove(comp); 346 } else { 347 getContentPane().remove(comp); 348 } 349 } 350 351 352 363 public void setLayout(LayoutManager manager) { 364 if(isRootPaneCheckingEnabled()) { 365 getContentPane().setLayout(manager); 366 } 367 else { 368 super.setLayout(manager); 369 } 370 } 371 372 373 380 public JRootPane getRootPane() { 381 return rootPane; 382 } 383 384 385 396 protected void setRootPane(JRootPane root) { 397 if(rootPane != null) { 398 remove(rootPane); 399 } 400 rootPane = root; 401 if(rootPane != null) { 402 boolean checkingEnabled = isRootPaneCheckingEnabled(); 403 try { 404 setRootPaneCheckingEnabled(false); 405 add(rootPane, BorderLayout.CENTER); 406 } 407 finally { 408 setRootPaneCheckingEnabled(checkingEnabled); 409 } 410 } 411 } 412 413 414 422 public Container getContentPane() { 423 return getRootPane().getContentPane(); 424 } 425 426 442 public void setContentPane(Container contentPane) { 443 getRootPane().setContentPane(contentPane); 444 } 445 446 453 public JLayeredPane getLayeredPane() { 454 return getRootPane().getLayeredPane(); 455 } 456 457 472 public void setLayeredPane(JLayeredPane layeredPane) { 473 getRootPane().setLayeredPane(layeredPane); 474 } 475 476 483 public Component getGlassPane() { 484 return getRootPane().getGlassPane(); 485 } 486 487 499 public void setGlassPane(Component glassPane) { 500 getRootPane().setGlassPane(glassPane); 501 } 502 503 513 protected String paramString() { 514 String rootPaneCheckingEnabledString = (rootPaneCheckingEnabled ? 515 "true" : "false"); 516 517 return super.paramString() + 518 ",rootPaneCheckingEnabled=" + rootPaneCheckingEnabledString; 519 } 520 521 522 526 527 protected AccessibleContext accessibleContext = null; 528 529 538 public AccessibleContext getAccessibleContext() { 539 if (accessibleContext == null) { 540 accessibleContext = new AccessibleJWindow(); 541 } 542 return accessibleContext; 543 } 544 545 546 552 protected class AccessibleJWindow extends AccessibleAWTWindow { 553 } 555 556 } 557 | Popular Tags |