1. /*
  2. * @(#)WindowsDesktopManager.java 1.18 03/12/19
  3. *
  4. * Copyright 2004 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.18 12/19/03
  30. * @author Thomas Ball
  31. */
  32. public class WindowsDesktopManager extends DefaultDesktopManager
  33. implements java.io.Serializable, javax.swing.plaf.UIResource {
  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. //Special case. If key binding was used to select next
  49. //frame instead of minimizing the icon via the minimize
  50. //icon.
  51. if (!currentFrame.isIcon()) {
  52. currentFrame.setMaximum(false);
  53. }
  54. if (f.isMaximizable()) {
  55. if (!f.isMaximum()) {
  56. f.setMaximum(true);
  57. } else if (f.isMaximum() && f.isIcon()) {
  58. f.setIcon(false);
  59. } else {
  60. f.setMaximum(false);
  61. }
  62. }
  63. }
  64. if (currentFrame.isSelected()) {
  65. currentFrame.setSelected(false);
  66. }
  67. }
  68. if (!f.isSelected()) {
  69. f.setSelected(true);
  70. }
  71. currentFrame = f;
  72. } catch (PropertyVetoException e) {}
  73. }
  74. }