1. /*
  2. * @(#)WindowsDesktopManager.java 1.15 03/01/23
  3. *
  4. * Copyright 2003 Sun Microsystems, Inc. All rights reserved.
  5. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
  6. */
  7. package com.sun.java.swing.plaf.windows;
  8. import javax.swing.DefaultDesktopManager;
  9. import javax.swing.JInternalFrame;
  10. import javax.swing.JLayeredPane;
  11. import java.awt.Component;
  12. import java.awt.Container;
  13. import java.awt.Dimension;
  14. import java.beans.PropertyVetoException;
  15. import java.util.Vector;
  16. /**
  17. * This class implements a DesktopManager which more closely follows
  18. * the MDI model than the DefaultDesktopManager. Unlike the
  19. * DefaultDesktopManager policy, MDI requires that the selected
  20. * and activated child frames are the same, and that that frame
  21. * always be the top-most window.
  22. * <p>
  23. * The maximized state is managed by the DesktopManager with MDI,
  24. * instead of just being a property of the individual child frame.
  25. * This means that if the currently selected window is maximized
  26. * and another window is selected, that new window will be maximized.
  27. *
  28. * @see javax.swing.DefaultDesktopManager
  29. * @version 1.15 01/23/03
  30. * @author Thomas Ball
  31. */
  32. public class WindowsDesktopManager extends DefaultDesktopManager
  33. implements java.io.Serializable {
  34. /* The frame which is currently selected/activated.
  35. * We store this value to enforce MDI's single-selection model.
  36. */
  37. JInternalFrame currentFrame;
  38. JInternalFrame initialFrame;
  39. public void activateFrame(JInternalFrame f) {
  40. try {
  41. super.activateFrame(f);
  42. if (currentFrame != null && f != currentFrame) {
  43. // If the current frame is maximized, transfer that
  44. // attribute to the frame being activated.
  45. if (currentFrame.isMaximum() &&
  46. (f.getClientProperty("JInternalFrame.frameType") !=
  47. "optionDialog") ) {
  48. currentFrame.setMaximum(false);
  49. f.setMaximum(true);
  50. }
  51. if (currentFrame.isSelected()) {
  52. currentFrame.setSelected(false);
  53. }
  54. }
  55. if (!f.isSelected()) {
  56. f.setSelected(true);
  57. }
  58. currentFrame = f;
  59. } catch (PropertyVetoException e) {}
  60. }
  61. }