1. /*
  2. * @(#)WindowsDesktopPaneUI.java 1.13 01/11/29
  3. *
  4. * Copyright 2002 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.*;
  9. import javax.swing.plaf.basic.*;
  10. import javax.swing.plaf.ComponentUI;
  11. import java.awt.event.*;
  12. /**
  13. * Windows desktop pane.
  14. * <p>
  15. * <strong>Warning:</strong>
  16. * Serialized objects of this class will not be compatible with
  17. * future Swing releases. The current serialization support is appropriate
  18. * for short term storage or RMI between applications running the same
  19. * version of Swing. A future release of Swing will provide support for
  20. * long term persistence.
  21. *
  22. * @version %i% 11/29/01
  23. * @author David Kloba
  24. */
  25. public class WindowsDesktopPaneUI extends BasicDesktopPaneUI
  26. {
  27. public static ComponentUI createUI(JComponent c) {
  28. return new WindowsDesktopPaneUI();
  29. }
  30. protected void installDesktopManager() {
  31. if(desktop.getDesktopManager() == null) {
  32. desktopManager = new WindowsDesktopManager();
  33. desktop.setDesktopManager(desktopManager);
  34. }
  35. }
  36. void switchFrame(boolean next) {
  37. WindowsDesktopManager dm =
  38. (WindowsDesktopManager)desktop.getDesktopManager();
  39. if (dm == null) {
  40. return;
  41. }
  42. if (next) {
  43. dm.activateNextFrame();
  44. } else {
  45. dm.activatePreviousFrame();
  46. }
  47. }
  48. protected void installKeyboardActions() {
  49. super.installKeyboardActions();
  50. desktop.registerKeyboardAction(
  51. new ActionListener() {
  52. public void actionPerformed(ActionEvent e) {
  53. switchFrame(true);
  54. }
  55. },
  56. KeyStroke.getKeyStroke(KeyEvent.VK_F6, InputEvent.CTRL_MASK),
  57. JComponent.WHEN_IN_FOCUSED_WINDOW);
  58. desktop.registerKeyboardAction(
  59. new ActionListener() {
  60. public void actionPerformed(ActionEvent e) {
  61. switchFrame(false);
  62. }
  63. },
  64. KeyStroke.getKeyStroke(KeyEvent.VK_F6,
  65. InputEvent.CTRL_MASK | InputEvent.SHIFT_MASK),
  66. JComponent.WHEN_IN_FOCUSED_WINDOW);
  67. // Request focus if it isn't set.
  68. if(!desktop.requestDefaultFocus()) {
  69. desktop.requestFocus();
  70. }
  71. }
  72. protected void uninstallKeyboardActions() {
  73. super.uninstallKeyboardActions();
  74. desktop.resetKeyboardActions();
  75. }
  76. }