1. /*
  2. * @(#)WindowsDesktopPaneUI.java 1.15 00/02/02
  3. *
  4. * Copyright 1997-2000 Sun Microsystems, Inc. All Rights Reserved.
  5. *
  6. * This software is the proprietary information of Sun Microsystems, Inc.
  7. * Use is subject to license terms.
  8. *
  9. */
  10. package com.sun.java.swing.plaf.windows;
  11. import javax.swing.*;
  12. import javax.swing.plaf.basic.*;
  13. import javax.swing.plaf.ComponentUI;
  14. import java.awt.event.*;
  15. /**
  16. * Windows desktop pane.
  17. * <p>
  18. * <strong>Warning:</strong>
  19. * Serialized objects of this class will not be compatible with
  20. * future Swing releases. The current serialization support is appropriate
  21. * for short term storage or RMI between applications running the same
  22. * version of Swing. A future release of Swing will provide support for
  23. * long term persistence.
  24. *
  25. * @version %i% 02/02/00
  26. * @author David Kloba
  27. */
  28. public class WindowsDesktopPaneUI extends BasicDesktopPaneUI
  29. {
  30. public static ComponentUI createUI(JComponent c) {
  31. return new WindowsDesktopPaneUI();
  32. }
  33. protected void installDesktopManager() {
  34. if(desktop.getDesktopManager() == null) {
  35. desktopManager = new WindowsDesktopManager();
  36. desktop.setDesktopManager(desktopManager);
  37. }
  38. }
  39. void switchFrame(boolean next) {
  40. WindowsDesktopManager dm =
  41. (WindowsDesktopManager)desktop.getDesktopManager();
  42. if (dm == null) {
  43. return;
  44. }
  45. if (next) {
  46. dm.activateNextFrame();
  47. } else {
  48. dm.activatePreviousFrame();
  49. }
  50. }
  51. protected void installKeyboardActions() {
  52. super.installKeyboardActions();
  53. ActionMap map = SwingUtilities.getUIActionMap(desktop);
  54. if (map != null) {
  55. map.put("selectNextFrame", new SwitchFrameAction(true));
  56. map.put("selectPreviousFrame", new SwitchFrameAction(false));
  57. }
  58. // Request focus if it isn't set.
  59. if(!desktop.requestDefaultFocus()) {
  60. desktop.requestFocus();
  61. }
  62. }
  63. class SwitchFrameAction extends AbstractAction {
  64. boolean direction;
  65. SwitchFrameAction(boolean direction) {
  66. this.direction = direction;
  67. }
  68. public void actionPerformed(ActionEvent e) {
  69. switchFrame(direction);
  70. }
  71. }
  72. }