1 7 8 package com.sun.java.swing.plaf.motif; 9 10 import java.awt.*; 11 import java.awt.event.*; 12 import javax.swing.*; 13 import javax.swing.event.*; 14 15 import java.util.EventListener ; 16 17 import javax.swing.plaf.basic.*; 18 import javax.swing.border.*; 19 import javax.swing.plaf.*; 20 21 22 35 public class MotifInternalFrameUI extends BasicInternalFrameUI { 36 37 Color color; 38 Color highlight; 39 Color shadow; 40 MotifInternalFrameTitlePane titlePane; 41 42 50 @Deprecated 51 protected KeyStroke closeMenuKey; 52 53 54 public static ComponentUI createUI(JComponent w) { 58 return new MotifInternalFrameUI((JInternalFrame)w); 59 } 60 61 public MotifInternalFrameUI(JInternalFrame w) { 62 super(w); 63 } 64 65 public void installUI(JComponent c) { 66 super.installUI(c); 67 setColors((JInternalFrame)c); 68 } 69 70 protected void installDefaults() { 71 Border frameBorder = frame.getBorder(); 72 frame.setLayout(internalFrameLayout = createLayoutManager()); 73 if (frameBorder == null || frameBorder instanceof UIResource) { 74 frame.setBorder(new MotifBorders.InternalFrameBorder(frame)); 75 } 76 } 77 78 79 protected void installKeyboardActions(){ 80 super.installKeyboardActions(); 81 closeMenuKey = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0); 84 } 85 86 87 protected void uninstallDefaults() { 88 LookAndFeel.uninstallBorder(frame); 89 frame.setLayout(null); 90 internalFrameLayout = null; 91 } 92 93 private JInternalFrame getFrame(){ 94 return frame; 95 } 96 97 public JComponent createNorthPane(JInternalFrame w) { 98 titlePane = new MotifInternalFrameTitlePane(w); 99 return titlePane; 100 } 101 102 public Dimension getMaximumSize(JComponent x) { 103 return Toolkit.getDefaultToolkit().getScreenSize(); 104 } 105 106 protected void uninstallKeyboardActions(){ 107 super.uninstallKeyboardActions(); 108 if (isKeyBindingRegistered()){ 109 JInternalFrame.JDesktopIcon di = frame.getDesktopIcon(); 110 SwingUtilities.replaceUIActionMap(di, null); 111 SwingUtilities.replaceUIInputMap(di, JComponent.WHEN_IN_FOCUSED_WINDOW, 112 null); 113 } 114 } 115 116 protected void setupMenuOpenKey(){ 117 super.setupMenuOpenKey(); 118 ActionMap map = SwingUtilities.getUIActionMap(frame); 119 if (map != null) { 120 map.put("showSystemMenu", new AbstractAction(){ 125 public void actionPerformed(ActionEvent e){ 126 titlePane.showSystemMenu(); 127 } 128 public boolean isEnabled(){ 129 return isKeyBindingActive(); 130 } 131 }); 132 } 133 } 134 135 protected void setupMenuCloseKey(){ 136 ActionMap map = SwingUtilities.getUIActionMap(frame); 137 if (map != null) { 138 map.put("hideSystemMenu", new AbstractAction(){ 139 public void actionPerformed(ActionEvent e){ 140 titlePane.hideSystemMenu(); 141 } 142 public boolean isEnabled(){ 143 return isKeyBindingActive(); 144 } 145 }); 146 } 147 148 JInternalFrame.JDesktopIcon di = frame.getDesktopIcon(); 151 InputMap diInputMap = SwingUtilities.getUIInputMap 152 (di, JComponent.WHEN_IN_FOCUSED_WINDOW); 153 if (diInputMap == null) { 154 Object [] bindings = (Object [])UIManager.get 155 ("DesktopIcon.windowBindings"); 156 if (bindings != null) { 157 diInputMap = LookAndFeel.makeComponentInputMap(di, bindings); 158 159 SwingUtilities.replaceUIInputMap(di, JComponent. 160 WHEN_IN_FOCUSED_WINDOW, 161 diInputMap); 162 } 163 } 164 ActionMap diActionMap = SwingUtilities.getUIActionMap(di); 165 if (diActionMap == null) { 166 diActionMap = new ActionMapUIResource(); 167 diActionMap.put("hideSystemMenu", new AbstractAction(){ 168 public void actionPerformed(ActionEvent e){ 169 JInternalFrame.JDesktopIcon icon = getFrame(). 170 getDesktopIcon(); 171 MotifDesktopIconUI micon = (MotifDesktopIconUI)icon. 172 getUI(); 173 micon.hideSystemMenu(); 174 } 175 public boolean isEnabled(){ 176 return isKeyBindingActive(); 177 } 178 }); 179 SwingUtilities.replaceUIActionMap(di, diActionMap); 180 } 181 } 182 183 185 protected void activateFrame(JInternalFrame f) { 186 super.activateFrame(f); 187 setColors(f); 188 } 189 191 protected void deactivateFrame(JInternalFrame f) { 192 setColors(f); 193 super.deactivateFrame(f); 194 } 195 196 void setColors(JInternalFrame frame) { 197 if (frame.isSelected()) { 198 color = UIManager.getColor("InternalFrame.activeTitleBackground"); 199 } else { 200 color = UIManager.getColor("InternalFrame.inactiveTitleBackground"); 201 } 202 highlight = color.brighter(); 203 shadow = color.darker().darker(); 204 titlePane.setColors(color, highlight, shadow); 205 } 206 } 207 | Popular Tags |