1 /* 2 * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. Oracle designates this 8 * particular file as subject to the "Classpath" exception as provided 9 * by Oracle in the LICENSE file that accompanied this code. 10 * 11 * This code is distributed in the hope that it will be useful, but WITHOUT 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 * version 2 for more details (a copy is included in the LICENSE file that 15 * accompanied this code). 16 * 17 * You should have received a copy of the GNU General Public License version 18 * 2 along with this work; if not, write to the Free Software Foundation, 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 * 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 * or visit www.oracle.com if you need additional information or have any 23 * questions. 24 */ 25 26 package javax.swing.plaf.basic; 27 28 import java.awt.Font; 29 import java.awt.Color; 30 import java.awt.SystemColor; 31 import java.awt.event.*; 32 import java.awt.Insets; 33 import java.awt.Component; 34 import java.awt.Container; 35 import java.awt.FocusTraversalPolicy; 36 import java.awt.AWTEvent; 37 import java.awt.Toolkit; 38 import java.awt.Point; 39 import java.net.URL; 40 import java.io.*; 41 import java.awt.Dimension; 42 import java.awt.KeyboardFocusManager; 43 import java.security.AccessController; 44 import java.security.PrivilegedAction; 45 import java.util.*; 46 import java.lang.reflect.*; 47 import javax.sound.sampled.*; 48 49 import sun.awt.AppContext; 50 import sun.awt.SunToolkit; 51 52 import sun.swing.SwingLazyValue; 53 import sun.swing.SwingUtilities2; 54 55 import javax.swing.LookAndFeel; 56 import javax.swing.AbstractAction; 57 import javax.swing.Action; 58 import javax.swing.ActionMap; 59 import javax.swing.BorderFactory; 60 import javax.swing.JComponent; 61 import javax.swing.ImageIcon; 62 import javax.swing.UIDefaults; 63 import javax.swing.UIManager; 64 import javax.swing.KeyStroke; 65 import javax.swing.JTextField; 66 import javax.swing.DefaultListCellRenderer; 67 import javax.swing.FocusManager; 68 import javax.swing.LayoutFocusTraversalPolicy; 69 import javax.swing.SwingUtilities; 70 import javax.swing.MenuSelectionManager; 71 import javax.swing.MenuElement; 72 import javax.swing.border.*; 73 import javax.swing.plaf.*; 74 import javax.swing.text.JTextComponent; 75 import javax.swing.text.DefaultEditorKit; 76 import javax.swing.JInternalFrame; 77 import java.beans.PropertyVetoException; 78 import java.awt.Window; 79 import java.beans.PropertyChangeListener; 80 import java.beans.PropertyChangeEvent; 81 82 83 /** 84 * A base class to use in creating a look and feel for Swing. 85 * <p> 86 * Each of the {@code ComponentUI}s provided by {@code 87 * BasicLookAndFeel} derives its behavior from the defaults 88 * table. Unless otherwise noted each of the {@code ComponentUI} 89 * implementations in this package document the set of defaults they 90 * use. Unless otherwise noted the defaults are installed at the time 91 * {@code installUI} is invoked, and follow the recommendations 92 * outlined in {@code LookAndFeel} for installing defaults. 93 * <p> 94 * <strong>Warning:</strong> 95 * Serialized objects of this class will not be compatible with 96 * future Swing releases. The current serialization support is 97 * appropriate for short term storage or RMI between applications running 98 * the same version of Swing. As of 1.4, support for long term storage 99 * of all JavaBeans<sup><font size="-2">TM</font></sup> 100 * has been added to the <code>java.beans</code> package. 101 * Please see {@link java.beans.XMLEncoder}. 102 * 103 * @author unattributed 104 */ 105 public abstract class BasicLookAndFeel extends LookAndFeel implements Serializable 106 { 107 /** 108 * Whether or not the developer has created a JPopupMenu. 109 */ 110 static boolean needsEventHelper; 111 112 /** 113 * Lock used when manipulating clipPlaying. 114 */ 115 private transient Object audioLock = new Object(); 116 /** 117 * The Clip that is currently playing (set in AudioAction). 118 */ 119 private Clip clipPlaying; 120 121 AWTEventHelper invocator = null; 122 123 /* 124 * Listen for our AppContext being disposed 125 */ 126 private PropertyChangeListener disposer = null; 127 128 /** 129 * Returns the look and feel defaults. The returned {@code UIDefaults} 130 * is populated by invoking, in order, {@code initClassDefaults}, 131 * {@code initSystemColorDefaults} and {@code initComponentDefaults}. 132 * <p> 133 * While this method is public, it should only be invoked by the 134 * {@code UIManager} when the look and feel is set as the current 135 * look and feel and after {@code initialize} has been invoked. 136 * 137 * @return the look and feel defaults 138 * 139 * @see #initClassDefaults 140 * @see #initSystemColorDefaults 141 * @see #initComponentDefaults 142 */ 143 public UIDefaults getDefaults() { 144 UIDefaults table = new UIDefaults(610, 0.75f); 145 146 initClassDefaults(table); 147 initSystemColorDefaults(table); 148 initComponentDefaults(table); 149 150 return table; 151 } 152 153 /** 154 * {@inheritDoc} 155 */ 156 public void initialize() { 157 if (needsEventHelper) { 158 installAWTEventListener(); 159 } 160 } 161 162 void installAWTEventListener() { 163 if (invocator == null) { 164 invocator = new AWTEventHelper(); 165 needsEventHelper = true; 166 167 // Add a PropertyChangeListener to our AppContext so we're alerted 168 // when the AppContext is disposed(), at which time this laf should 169 // be uninitialize()d. 170 disposer = new PropertyChangeListener() { 171 public void propertyChange(PropertyChangeEvent prpChg) { 172 uninitialize(); 173 } 174 }; 175 AppContext.getAppContext().addPropertyChangeListener( 176 AppContext.GUI_DISPOSED, 177 disposer); 178 } 179 } 180 181 /** 182 * {@inheritDoc} 183 */ 184 public void uninitialize() { 185 AppContext context = AppContext.getAppContext(); 186 synchronized (BasicPopupMenuUI.MOUSE_GRABBER_KEY) { 187 Object grabber = context.get(BasicPopupMenuUI.MOUSE_GRABBER_KEY); 188 if (grabber != null) { 189 ((BasicPopupMenuUI.MouseGrabber)grabber).uninstall(); 190 } 191 } 192 synchronized (BasicPopupMenuUI.MENU_KEYBOARD_HELPER_KEY) { 193 Object helper = 194 context.get(BasicPopupMenuUI.MENU_KEYBOARD_HELPER_KEY); 195 if (helper != null) { 196 ((BasicPopupMenuUI.MenuKeyboardHelper)helper).uninstall(); 197 } 198 } 199 200 if(invocator != null) { 201 AccessController.doPrivileged(invocator); 202 invocator = null; 203 } 204 205 if (disposer != null) { 206 // Note that we're likely calling removePropertyChangeListener() 207 // during the course of AppContext.firePropertyChange(). 208 // However, EventListenerAggreggate has code to safely modify 209 // the list under such circumstances. 210 context.removePropertyChangeListener(AppContext.GUI_DISPOSED, 211 disposer); 212 disposer = null; 213 } 214 } 215 216 /** 217 * Populates {@code table} with mappings from {@code uiClassID} to the 218 * fully qualified name of the ui class. The value for a 219 * particular {@code uiClassID} is {@code 220 * "javax.swing.plaf.basic.Basic + uiClassID"}. For example, the 221 * value for the {@code uiClassID} {@code TreeUI} is {@code 222 * "javax.swing.plaf.basic.BasicTreeUI"}. 223 * 224 * @param table the {@code UIDefaults} instance the entries are 225 * added to 226 * @throws NullPointerException if {@code table} is {@code null} 227 * 228 * @see javax.swing.LookAndFeel 229 * @see #getDefaults 230 */ 231 protected void initClassDefaults(UIDefaults table) 232 { 233 final String basicPackageName = "javax.swing.plaf.basic."; 234 Object[] uiDefaults = { 235 "ButtonUI", basicPackageName + "BasicButtonUI", 236 "CheckBoxUI", basicPackageName + "BasicCheckBoxUI", 237 "ColorChooserUI", basicPackageName + "BasicColorChooserUI", 238 "FormattedTextFieldUI", basicPackageName + "BasicFormattedTextFieldUI", 239 "MenuBarUI", basicPackageName + "BasicMenuBarUI", 240 "MenuUI", basicPackageName + "BasicMenuUI", 241 "MenuItemUI", basicPackageName + "BasicMenuItemUI", 242 "CheckBoxMenuItemUI", basicPackageName + "BasicCheckBoxMenuItemUI", 243 "RadioButtonMenuItemUI", basicPackageName + "BasicRadioButtonMenuItemUI", 244 "RadioButtonUI", basicPackageName + "BasicRadioButtonUI", 245 "ToggleButtonUI", basicPackageName + "BasicToggleButtonUI", 246 "PopupMenuUI", basicPackageName + "BasicPopupMenuUI", 247 "ProgressBarUI", basicPackageName + "BasicProgressBarUI", 248 "ScrollBarUI", basicPackageName + "BasicScrollBarUI", 249 "ScrollPaneUI", basicPackageName + "BasicScrollPaneUI", 250 "SplitPaneUI", basicPackageName + "BasicSplitPaneUI", 251 "SliderUI", basicPackageName + "BasicSliderUI", 252 "SeparatorUI", basicPackageName + "BasicSeparatorUI", 253 "SpinnerUI", basicPackageName + "BasicSpinnerUI", 254 "ToolBarSeparatorUI", basicPackageName + "BasicToolBarSeparatorUI", 255 "PopupMenuSeparatorUI", basicPackageName + "BasicPopupMenuSeparatorUI", 256 "TabbedPaneUI", basicPackageName + "BasicTabbedPaneUI", 257 "TextAreaUI", basicPackageName + "BasicTextAreaUI", 258 "TextFieldUI", basicPackageName + "BasicTextFieldUI", 259 "PasswordFieldUI", basicPackageName + "BasicPasswordFieldUI", 260 "TextPaneUI", basicPackageName + "BasicTextPaneUI", 261 "EditorPaneUI", basicPackageName + "BasicEditorPaneUI", 262 "TreeUI", basicPackageName + "BasicTreeUI", 263 "LabelUI", basicPackageName + "BasicLabelUI", 264 "ListUI", basicPackageName + "BasicListUI", 265 "ToolBarUI", basicPackageName + "BasicToolBarUI", 266 "ToolTipUI", basicPackageName + "BasicToolTipUI", 267 "ComboBoxUI", basicPackageName + "BasicComboBoxUI", 268 "TableUI", basicPackageName + "BasicTableUI", 269 "TableHeaderUI", basicPackageName + "BasicTableHeaderUI", 270 "InternalFrameUI", basicPackageName + "BasicInternalFrameUI", 271 "DesktopPaneUI", basicPackageName + "BasicDesktopPaneUI", 272 "DesktopIconUI", basicPackageName + "BasicDesktopIconUI", 273 "FileChooserUI", basicPackageName + "BasicFileChooserUI", 274 "OptionPaneUI", basicPackageName + "BasicOptionPaneUI", 275 "PanelUI", basicPackageName + "BasicPanelUI", 276 "ViewportUI", basicPackageName + "BasicViewportUI", 277 "RootPaneUI", basicPackageName + "BasicRootPaneUI", 278 }; 279 280 table.putDefaults(uiDefaults); 281 } 282 283 /** 284 * Populates {@code table} with system colors. This creates an 285 * array of {@code name-color} pairs and invokes {@code 286 * loadSystemColors}. 287 * <p> 288 * The name is a {@code String} that corresponds to the name of 289 * one of the static {@code SystemColor} fields in the {@code 290 * SystemColor} class. A name-color pair is created for every 291 * such {@code SystemColor} field. 292 * <p> 293 * The {@code color} corresponds to a hex {@code String} as 294 * understood by {@code Color.decode}. For example, one of the 295 * {@code name-color} pairs is {@code 296 * "desktop"-"#005C5C"}. This corresponds to the {@code 297 * SystemColor} field {@code desktop}, with a color value of 298 * {@code new Color(0x005C5C)}. 299 * <p> 300 * The following shows two of the {@code name-color} pairs: 301 * <pre> 302 * String[] nameColorPairs = new String[] { 303 * "desktop", "#005C5C", 304 * "activeCaption", "#000080" }; 305 * loadSystemColors(table, nameColorPairs, isNativeLookAndFeel()); 306 * </pre> 307 * 308 * As previously stated, this invokes {@code loadSystemColors} 309 * with the supplied {@code table} and {@code name-color} pair 310 * array. The last argument to {@code loadSystemColors} indicates 311 * whether the value of the field in {@code SystemColor} should be 312 * used. This method passes the value of {@code 313 * isNativeLookAndFeel()} as the last argument to {@code loadSystemColors}. 314 * 315 * @param table the {@code UIDefaults} object the values are added to 316 * @throws NullPointerException if {@code table} is {@code null} 317 * 318 * @see java.awt.SystemColor 319 * @see #getDefaults 320 * @see #loadSystemColors 321 */ 322 protected void initSystemColorDefaults(UIDefaults table) 323 { 324 String[] defaultSystemColors = { 325 "desktop", "#005C5C", /* Color of the desktop background */ 326 "activeCaption", "#000080", /* Color for captions (title bars) when they are active. */ 327 "activeCaptionText", "#FFFFFF", /* Text color for text in captions (title bars). */ 328 "activeCaptionBorder", "#C0C0C0", /* Border color for caption (title bar) window borders. */ 329 "inactiveCaption", "#808080", /* Color for captions (title bars) when not active. */ 330 "inactiveCaptionText", "#C0C0C0", /* Text color for text in inactive captions (title bars). */ 331 "inactiveCaptionBorder", "#C0C0C0", /* Border color for inactive caption (title bar) window borders. */ 332 "window", "#FFFFFF", /* Default color for the interior of windows */ 333 "windowBorder", "#000000", /* ??? */ 334 "windowText", "#000000", /* ??? */ 335 "menu", "#C0C0C0", /* Background color for menus */ 336 "menuText", "#000000", /* Text color for menus */ 337 "text", "#C0C0C0", /* Text background color */ 338 "textText", "#000000", /* Text foreground color */ 339 "textHighlight", "#000080", /* Text background color when selected */ 340 "textHighlightText", "#FFFFFF", /* Text color when selected */ 341 "textInactiveText", "#808080", /* Text color when disabled */ 342 "control", "#C0C0C0", /* Default color for controls (buttons, sliders, etc) */ 343 "controlText", "#000000", /* Default color for text in controls */ 344 "controlHighlight", "#C0C0C0", /* Specular highlight (opposite of the shadow) */ 345 "controlLtHighlight", "#FFFFFF", /* Highlight color for controls */ 346 "controlShadow", "#808080", /* Shadow color for controls */ 347 "controlDkShadow", "#000000", /* Dark shadow color for controls */ 348 "scrollbar", "#E0E0E0", /* Scrollbar background (usually the "track") */ 349 "info", "#FFFFE1", /* ??? */ 350 "infoText", "#000000" /* ??? */ 351 }; 352 353 loadSystemColors(table, defaultSystemColors, isNativeLookAndFeel()); 354 } 355 356 357 /** 358 * Populates {@code table} with the {@code name-color} pairs in 359 * {@code systemColors}. Refer to 360 * {@link #initSystemColorDefaults(UIDefaults)} for details on 361 * the format of {@code systemColors}. 362 * <p> 363 * An entry is added to {@code table} for each of the {@code name-color} 364 * pairs in {@code systemColors}. The entry key is 365 * the {@code name} of the {@code name-color} pair. 366 * <p> 367 * The value of the entry corresponds to the {@code color} of the 368 * {@code name-color} pair. The value of the entry is calculated 369 * in one of two ways. With either approach the value is always a 370 * {@code ColorUIResource}. 371 * <p> 372 * If {@code useNative} is {@code false}, the {@code color} is 373 * created by using {@code Color.decode} to convert the {@code 374 * String} into a {@code Color}. If {@code decode} can not convert 375 * the {@code String} into a {@code Color} ({@code 376 * NumberFormatException} is thrown) then a {@code 377 * ColorUIResource} of black is used. 378 * <p> 379 * If {@code useNative} is {@code true}, the {@code color} is the 380 * value of the field in {@code SystemColor} with the same name as 381 * the {@code name} of the {@code name-color} pair. If the field 382 * is not valid, a {@code ColorUIResource} of black is used. 383 * 384 * @param table the {@code UIDefaults} object the values are added to 385 * @param systemColors array of {@code name-color} pairs as described 386 * in {@link #initSystemColorDefaults(UIDefaults)} 387 * @param useNative whether the color is obtained from {@code SystemColor} 388 * or {@code Color.decode} 389 * @throws NullPointerException if {@code systemColors} is {@code null}; or 390 * {@code systemColors} is not empty, and {@code table} is 391 * {@code null}; or one of the 392 * names of the {@code name-color} pairs is {@code null}; or 393 * {@code useNative} is {@code false} and one of the 394 * {@code colors} of the {@code name-color} pairs is {@code null} 395 * @throws ArrayIndexOutOfBoundsException if {@code useNative} is 396 * {@code false} and {@code systemColors.length} is odd 397 * 398 * @see #initSystemColorDefaults(javax.swing.UIDefaults) 399 * @see java.awt.SystemColor 400 * @see java.awt.Color#decode(String) 401 */ 402 protected void loadSystemColors(UIDefaults table, String[] systemColors, boolean useNative) 403 { 404 /* PENDING(hmuller) We don't load the system colors below because 405 * they're not reliable. Hopefully we'll be able to do better in 406 * a future version of AWT. 407 */ 408 if (useNative) { 409 for(int i = 0; i < systemColors.length; i += 2) { 410 Color color = Color.black; 411 try { 412 String name = systemColors[i]; 413 color = (Color)(SystemColor.class.getField(name).get(null)); 414 } catch (Exception e) { 415 } 416 table.put(systemColors[i], new ColorUIResource(color)); 417 } 418 } else { 419 for(int i = 0; i < systemColors.length; i += 2) { 420 Color color = Color.black; 421 try { 422 color = Color.decode(systemColors[i + 1]); 423 } 424 catch(NumberFormatException e) { 425 e.printStackTrace(); 426 } 427 table.put(systemColors[i], new ColorUIResource(color)); 428 } 429 } 430 } 431 /** 432 * Initialize the defaults table with the name of the ResourceBundle 433 * used for getting localized defaults. Also initialize the default 434 * locale used when no locale is passed into UIDefaults.get(). The 435 * default locale should generally not be relied upon. It is here for 436 * compatability with releases prior to 1.4. 437 */ 438 private void initResourceBundle(UIDefaults table) { 439 table.setDefaultLocale( Locale.getDefault() ); 440 table.addResourceBundle( "com.sun.swing.internal.plaf.basic.resources.basic" ); 441 } 442 443 /** 444 * Populates {@code table} with the defaults for the basic look and 445 * feel. 446 * 447 * @param table the {@code UIDefaults} to add the values to 448 * @throws NullPointerException if {@code table} is {@code null} 449 */ 450 protected void initComponentDefaults(UIDefaults table) 451 { 452 453 initResourceBundle(table); 454 455 // *** Shared Integers 456 Integer fiveHundred = new Integer(500); 457 458 // *** Shared Longs 459 Long oneThousand = new Long(1000); 460 461 // *** Shared Fonts 462 Integer twelve = new Integer(12); 463 Integer fontPlain = new Integer(Font.PLAIN); 464 Integer fontBold = new Integer(Font.BOLD); 465 Object dialogPlain12 = new SwingLazyValue( 466 "javax.swing.plaf.FontUIResource", 467 null, 468 new Object[] {Font.DIALOG, fontPlain, twelve}); 469 Object serifPlain12 = new SwingLazyValue( 470 "javax.swing.plaf.FontUIResource", 471 null, 472 new Object[] {Font.SERIF, fontPlain, twelve}); 473 Object sansSerifPlain12 = new SwingLazyValue( 474 "javax.swing.plaf.FontUIResource", 475 null, 476 new Object[] {Font.SANS_SERIF, fontPlain, twelve}); 477 Object monospacedPlain12 = new SwingLazyValue( 478 "javax.swing.plaf.FontUIResource", 479 null, 480 new Object[] {Font.MONOSPACED, fontPlain, twelve}); 481 Object dialogBold12 = new SwingLazyValue( 482 "javax.swing.plaf.FontUIResource", 483 null, 484 new Object[] {Font.DIALOG, fontBold, twelve}); 485 486 487 // *** Shared Colors 488 ColorUIResource red = new ColorUIResource(Color.red); 489 ColorUIResource black = new ColorUIResource(Color.black); 490 ColorUIResource white = new ColorUIResource(Color.white); 491 ColorUIResource yellow = new ColorUIResource(Color.yellow); 492 ColorUIResource gray = new ColorUIResource(Color.gray); 493 ColorUIResource lightGray = new ColorUIResource(Color.lightGray); 494 ColorUIResource darkGray = new ColorUIResource(Color.darkGray); 495 ColorUIResource scrollBarTrack = new ColorUIResource(224, 224, 224); 496 497 Color control = table.getColor("control"); 498 Color controlDkShadow = table.getColor("controlDkShadow"); 499 Color controlHighlight = table.getColor("controlHighlight"); 500 Color controlLtHighlight = table.getColor("controlLtHighlight"); 501 Color controlShadow = table.getColor("controlShadow"); 502 Color controlText = table.getColor("controlText"); 503 Color menu = table.getColor("menu"); 504 Color menuText = table.getColor("menuText"); 505 Color textHighlight = table.getColor("textHighlight"); 506 Color textHighlightText = table.getColor("textHighlightText"); 507 Color textInactiveText = table.getColor("textInactiveText"); 508 Color textText = table.getColor("textText"); 509 Color window = table.getColor("window"); 510 511 // *** Shared Insets 512 InsetsUIResource zeroInsets = new InsetsUIResource(0,0,0,0); 513 InsetsUIResource twoInsets = new InsetsUIResource(2,2,2,2); 514 InsetsUIResource threeInsets = new InsetsUIResource(3,3,3,3); 515 516 // *** Shared Borders 517 Object marginBorder = new SwingLazyValue( 518 "javax.swing.plaf.basic.BasicBorders$MarginBorder"); 519 Object etchedBorder = new SwingLazyValue( 520 "javax.swing.plaf.BorderUIResource", 521 "getEtchedBorderUIResource"); 522 Object loweredBevelBorder = new SwingLazyValue( 523 "javax.swing.plaf.BorderUIResource", 524 "getLoweredBevelBorderUIResource"); 525 526 Object popupMenuBorder = new SwingLazyValue( 527 "javax.swing.plaf.basic.BasicBorders", 528 "getInternalFrameBorder"); 529 530 Object blackLineBorder = new SwingLazyValue( 531 "javax.swing.plaf.BorderUIResource", 532 "getBlackLineBorderUIResource"); 533 Object focusCellHighlightBorder = new SwingLazyValue( 534 "javax.swing.plaf.BorderUIResource$LineBorderUIResource", 535 null, 536 new Object[] {yellow}); 537 538 Object noFocusBorder = new BorderUIResource.EmptyBorderUIResource(1,1,1,1); 539 540 Object tableHeaderBorder = new SwingLazyValue( 541 "javax.swing.plaf.BorderUIResource$BevelBorderUIResource", 542 null, 543 new Object[] { new Integer(BevelBorder.RAISED), 544 controlLtHighlight, 545 control, 546 controlDkShadow, 547 controlShadow }); 548 549 550 // *** Button value objects 551 552 Object buttonBorder = 553 new SwingLazyValue( 554 "javax.swing.plaf.basic.BasicBorders", 555 "getButtonBorder"); 556 557 Object buttonToggleBorder = 558 new SwingLazyValue( 559 "javax.swing.plaf.basic.BasicBorders", 560 "getToggleButtonBorder"); 561 562 Object radioButtonBorder = 563 new SwingLazyValue( 564 "javax.swing.plaf.basic.BasicBorders", 565 "getRadioButtonBorder"); 566 567 // *** FileChooser / FileView value objects 568 569 Object newFolderIcon = SwingUtilities2.makeIcon(getClass(), 570 BasicLookAndFeel.class, 571 "icons/NewFolder.gif"); 572 Object upFolderIcon = SwingUtilities2.makeIcon(getClass(), 573 BasicLookAndFeel.class, 574 "icons/UpFolder.gif"); 575 Object homeFolderIcon = SwingUtilities2.makeIcon(getClass(), 576 BasicLookAndFeel.class, 577 "icons/HomeFolder.gif"); 578 Object detailsViewIcon = SwingUtilities2.makeIcon(getClass(), 579 BasicLookAndFeel.class, 580 "icons/DetailsView.gif"); 581 Object listViewIcon = SwingUtilities2.makeIcon(getClass(), 582 BasicLookAndFeel.class, 583 "icons/ListView.gif"); 584 Object directoryIcon = SwingUtilities2.makeIcon(getClass(), 585 BasicLookAndFeel.class, 586 "icons/Directory.gif"); 587 Object fileIcon = SwingUtilities2.makeIcon(getClass(), 588 BasicLookAndFeel.class, 589 "icons/File.gif"); 590 Object computerIcon = SwingUtilities2.makeIcon(getClass(), 591 BasicLookAndFeel.class, 592 "icons/Computer.gif"); 593 Object hardDriveIcon = SwingUtilities2.makeIcon(getClass(), 594 BasicLookAndFeel.class, 595 "icons/HardDrive.gif"); 596 Object floppyDriveIcon = SwingUtilities2.makeIcon(getClass(), 597 BasicLookAndFeel.class, 598 "icons/FloppyDrive.gif"); 599 600 601 // *** InternalFrame value objects 602 603 Object internalFrameBorder = new SwingLazyValue( 604 "javax.swing.plaf.basic.BasicBorders", 605 "getInternalFrameBorder"); 606 607 // *** List value objects 608 609 Object listCellRendererActiveValue = new UIDefaults.ActiveValue() { 610 public Object createValue(UIDefaults table) { 611 return new DefaultListCellRenderer.UIResource(); 612 } 613 }; 614 615 616 // *** Menus value objects 617 618 Object menuBarBorder = 619 new SwingLazyValue( 620 "javax.swing.plaf.basic.BasicBorders", 621 "getMenuBarBorder"); 622 623 Object menuItemCheckIcon = 624 new SwingLazyValue( 625 "javax.swing.plaf.basic.BasicIconFactory", 626 "getMenuItemCheckIcon"); 627 628 Object menuItemArrowIcon = 629 new SwingLazyValue( 630 "javax.swing.plaf.basic.BasicIconFactory", 631 "getMenuItemArrowIcon"); 632 633 634 Object menuArrowIcon = 635 new SwingLazyValue( 636 "javax.swing.plaf.basic.BasicIconFactory", 637 "getMenuArrowIcon"); 638 639 Object checkBoxIcon = 640 new SwingLazyValue( 641 "javax.swing.plaf.basic.BasicIconFactory", 642 "getCheckBoxIcon"); 643 644 Object radioButtonIcon = 645 new SwingLazyValue( 646 "javax.swing.plaf.basic.BasicIconFactory", 647 "getRadioButtonIcon"); 648 649 Object checkBoxMenuItemIcon = 650 new SwingLazyValue( 651 "javax.swing.plaf.basic.BasicIconFactory", 652 "getCheckBoxMenuItemIcon"); 653 654 Object radioButtonMenuItemIcon = 655 new SwingLazyValue( 656 "javax.swing.plaf.basic.BasicIconFactory", 657 "getRadioButtonMenuItemIcon"); 658 659 Object menuItemAcceleratorDelimiter = "+"; 660 661 // *** OptionPane value objects 662 663 Object optionPaneMinimumSize = new DimensionUIResource(262, 90); 664 665 Integer zero = new Integer(0); 666 Object zeroBorder = new SwingLazyValue( 667 "javax.swing.plaf.BorderUIResource$EmptyBorderUIResource", 668 new Object[] {zero, zero, zero, zero}); 669 670 Integer ten = new Integer(10); 671 Object optionPaneBorder = new SwingLazyValue( 672 "javax.swing.plaf.BorderUIResource$EmptyBorderUIResource", 673 new Object[] {ten, ten, twelve, ten}); 674 675 Object optionPaneButtonAreaBorder = new SwingLazyValue( 676 "javax.swing.plaf.BorderUIResource$EmptyBorderUIResource", 677 new Object[] {new Integer(6), zero, zero, zero}); 678 679 680 // *** ProgessBar value objects 681 682 Object progressBarBorder = 683 new SwingLazyValue( 684 "javax.swing.plaf.basic.BasicBorders", 685 "getProgressBarBorder"); 686 687 // ** ScrollBar value objects 688 689 Object minimumThumbSize = new DimensionUIResource(8,8); 690 Object maximumThumbSize = new DimensionUIResource(4096,4096); 691 692 // ** Slider value objects 693 694 Object sliderFocusInsets = twoInsets; 695 696 Object toolBarSeparatorSize = new DimensionUIResource( 10, 10 ); 697 698 699 // *** SplitPane value objects 700 701 Object splitPaneBorder = 702 new SwingLazyValue( 703 "javax.swing.plaf.basic.BasicBorders", 704 "getSplitPaneBorder"); 705 Object splitPaneDividerBorder = 706 new SwingLazyValue( 707 "javax.swing.plaf.basic.BasicBorders", 708 "getSplitPaneDividerBorder"); 709 710 // ** TabbedBane value objects 711 712 Object tabbedPaneTabInsets = new InsetsUIResource(0, 4, 1, 4); 713 714 Object tabbedPaneTabPadInsets = new InsetsUIResource(2, 2, 2, 1); 715 716 Object tabbedPaneTabAreaInsets = new InsetsUIResource(3, 2, 0, 2); 717 718 Object tabbedPaneContentBorderInsets = new InsetsUIResource(2, 2, 3, 3); 719 720 721 // *** Text value objects 722 723 Object textFieldBorder = 724 new SwingLazyValue( 725 "javax.swing.plaf.basic.BasicBorders", 726 "getTextFieldBorder"); 727 728 Object editorMargin = threeInsets; 729 730 Object caretBlinkRate = fiveHundred; 731 Integer four = new Integer(4); 732 733 Object[] allAuditoryCues = new Object[] { 734 "CheckBoxMenuItem.commandSound", 735 "InternalFrame.closeSound", 736 "InternalFrame.maximizeSound", 737 "InternalFrame.minimizeSound", 738 "InternalFrame.restoreDownSound", 739 "InternalFrame.restoreUpSound", 740 "MenuItem.commandSound", 741 "OptionPane.errorSound", 742 "OptionPane.informationSound", 743 "OptionPane.questionSound", 744 "OptionPane.warningSound", 745 "PopupMenu.popupSound", 746 "RadioButtonMenuItem.commandSound"}; 747 748 Object[] noAuditoryCues = new Object[] {"mute"}; 749 750 // *** Component Defaults 751 752 Object[] defaults = { 753 // *** Auditory Feedback 754 "AuditoryCues.cueList", allAuditoryCues, 755 "AuditoryCues.allAuditoryCues", allAuditoryCues, 756 "AuditoryCues.noAuditoryCues", noAuditoryCues, 757 // this key defines which of the various cues to render. 758 // L&Fs that want auditory feedback NEED to override playList. 759 "AuditoryCues.playList", null, 760 761 // *** Buttons 762 "Button.defaultButtonFollowsFocus", Boolean.TRUE, 763 "Button.font", dialogPlain12, 764 "Button.background", control, 765 "Button.foreground", controlText, 766 "Button.shadow", controlShadow, 767 "Button.darkShadow", controlDkShadow, 768 "Button.light", controlHighlight, 769 "Button.highlight", controlLtHighlight, 770 "Button.border", buttonBorder, 771 "Button.margin", new InsetsUIResource(2, 14, 2, 14), 772 "Button.textIconGap", four, 773 "Button.textShiftOffset", zero, 774 "Button.focusInputMap", new UIDefaults.LazyInputMap(new Object[] { 775 "SPACE", "pressed", 776 "released SPACE", "released", 777 "ENTER", "pressed", 778 "released ENTER", "released" 779 }), 780 781 "ToggleButton.font", dialogPlain12, 782 "ToggleButton.background", control, 783 "ToggleButton.foreground", controlText, 784 "ToggleButton.shadow", controlShadow, 785 "ToggleButton.darkShadow", controlDkShadow, 786 "ToggleButton.light", controlHighlight, 787 "ToggleButton.highlight", controlLtHighlight, 788 "ToggleButton.border", buttonToggleBorder, 789 "ToggleButton.margin", new InsetsUIResource(2, 14, 2, 14), 790 "ToggleButton.textIconGap", four, 791 "ToggleButton.textShiftOffset", zero, 792 "ToggleButton.focusInputMap", 793 new UIDefaults.LazyInputMap(new Object[] { 794 "SPACE", "pressed", 795 "released SPACE", "released" 796 }), 797 798 "RadioButton.font", dialogPlain12, 799 "RadioButton.background", control, 800 "RadioButton.foreground", controlText, 801 "RadioButton.shadow", controlShadow, 802 "RadioButton.darkShadow", controlDkShadow, 803 "RadioButton.light", controlHighlight, 804 "RadioButton.highlight", controlLtHighlight, 805 "RadioButton.border", radioButtonBorder, 806 "RadioButton.margin", twoInsets, 807 "RadioButton.textIconGap", four, 808 "RadioButton.textShiftOffset", zero, 809 "RadioButton.icon", radioButtonIcon, 810 "RadioButton.focusInputMap", 811 new UIDefaults.LazyInputMap(new Object[] { 812 "SPACE", "pressed", 813 "released SPACE", "released", 814 "RETURN", "pressed" 815 }), 816 817 "CheckBox.font", dialogPlain12, 818 "CheckBox.background", control, 819 "CheckBox.foreground", controlText, 820 "CheckBox.border", radioButtonBorder, 821 "CheckBox.margin", twoInsets, 822 "CheckBox.textIconGap", four, 823 "CheckBox.textShiftOffset", zero, 824 "CheckBox.icon", checkBoxIcon, 825 "CheckBox.focusInputMap", 826 new UIDefaults.LazyInputMap(new Object[] { 827 "SPACE", "pressed", 828 "released SPACE", "released" 829 }), 830 "FileChooser.useSystemExtensionHiding", Boolean.FALSE, 831 832 // *** ColorChooser 833 "ColorChooser.font", dialogPlain12, 834 "ColorChooser.background", control, 835 "ColorChooser.foreground", controlText, 836 837 "ColorChooser.swatchesSwatchSize", new Dimension(10, 10), 838 "ColorChooser.swatchesRecentSwatchSize", new Dimension(10, 10), 839 "ColorChooser.swatchesDefaultRecentColor", control, 840 841 // *** ComboBox 842 "ComboBox.font", sansSerifPlain12, 843 "ComboBox.background", window, 844 "ComboBox.foreground", textText, 845 "ComboBox.buttonBackground", control, 846 "ComboBox.buttonShadow", controlShadow, 847 "ComboBox.buttonDarkShadow", controlDkShadow, 848 "ComboBox.buttonHighlight", controlLtHighlight, 849 "ComboBox.selectionBackground", textHighlight, 850 "ComboBox.selectionForeground", textHighlightText, 851 "ComboBox.disabledBackground", control, 852 "ComboBox.disabledForeground", textInactiveText, 853 "ComboBox.timeFactor", oneThousand, 854 "ComboBox.isEnterSelectablePopup", Boolean.FALSE, 855 "ComboBox.ancestorInputMap", 856 new UIDefaults.LazyInputMap(new Object[] { 857 "ESCAPE", "hidePopup", 858 "PAGE_UP", "pageUpPassThrough", 859 "PAGE_DOWN", "pageDownPassThrough", 860 "HOME", "homePassThrough", 861 "END", "endPassThrough", 862 "ENTER", "enterPressed" 863 }), 864 865 // *** FileChooser 866 867 "FileChooser.newFolderIcon", newFolderIcon, 868 "FileChooser.upFolderIcon", upFolderIcon, 869 "FileChooser.homeFolderIcon", homeFolderIcon, 870 "FileChooser.detailsViewIcon", detailsViewIcon, 871 "FileChooser.listViewIcon", listViewIcon, 872 "FileChooser.readOnly", Boolean.FALSE, 873 "FileChooser.usesSingleFilePane", Boolean.FALSE, 874 "FileChooser.ancestorInputMap", 875 new UIDefaults.LazyInputMap(new Object[] { 876 "ESCAPE", "cancelSelection", 877 "F5", "refresh", 878 }), 879 880 "FileView.directoryIcon", directoryIcon, 881 "FileView.fileIcon", fileIcon, 882 "FileView.computerIcon", computerIcon, 883 "FileView.hardDriveIcon", hardDriveIcon, 884 "FileView.floppyDriveIcon", floppyDriveIcon, 885 886 // *** InternalFrame 887 "InternalFrame.titleFont", dialogBold12, 888 "InternalFrame.borderColor", control, 889 "InternalFrame.borderShadow", controlShadow, 890 "InternalFrame.borderDarkShadow", controlDkShadow, 891 "InternalFrame.borderHighlight", controlLtHighlight, 892 "InternalFrame.borderLight", controlHighlight, 893 "InternalFrame.border", internalFrameBorder, 894 "InternalFrame.icon", SwingUtilities2.makeIcon(getClass(), 895 BasicLookAndFeel.class, 896 "icons/JavaCup16.png"), 897 898 /* Default frame icons are undefined for Basic. */ 899 "InternalFrame.maximizeIcon", 900 new SwingLazyValue( 901 "javax.swing.plaf.basic.BasicIconFactory", 902 "createEmptyFrameIcon"), 903 "InternalFrame.minimizeIcon", 904 new SwingLazyValue( 905 "javax.swing.plaf.basic.BasicIconFactory", 906 "createEmptyFrameIcon"), 907 "InternalFrame.iconifyIcon", 908 new SwingLazyValue( 909 "javax.swing.plaf.basic.BasicIconFactory", 910 "createEmptyFrameIcon"), 911 "InternalFrame.closeIcon", 912 new SwingLazyValue( 913 "javax.swing.plaf.basic.BasicIconFactory", 914 "createEmptyFrameIcon"), 915 // InternalFrame Auditory Cue Mappings 916 "InternalFrame.closeSound", null, 917 "InternalFrame.maximizeSound", null, 918 "InternalFrame.minimizeSound", null, 919 "InternalFrame.restoreDownSound", null, 920 "InternalFrame.restoreUpSound", null, 921 922 "InternalFrame.activeTitleBackground", table.get("activeCaption"), 923 "InternalFrame.activeTitleForeground", table.get("activeCaptionText"), 924 "InternalFrame.inactiveTitleBackground", table.get("inactiveCaption"), 925 "InternalFrame.inactiveTitleForeground", table.get("inactiveCaptionText"), 926 "InternalFrame.windowBindings", new Object[] { 927 "shift ESCAPE", "showSystemMenu", 928 "ctrl SPACE", "showSystemMenu", 929 "ESCAPE", "hideSystemMenu"}, 930 931 "InternalFrameTitlePane.iconifyButtonOpacity", Boolean.TRUE, 932 "InternalFrameTitlePane.maximizeButtonOpacity", Boolean.TRUE, 933 "InternalFrameTitlePane.closeButtonOpacity", Boolean.TRUE, 934 935 "DesktopIcon.border", internalFrameBorder, 936 937 "Desktop.minOnScreenInsets", threeInsets, 938 "Desktop.background", table.get("desktop"), 939 "Desktop.ancestorInputMap", 940 new UIDefaults.LazyInputMap(new Object[] { 941 "ctrl F5", "restore", 942 "ctrl F4", "close", 943 "ctrl F7", "move", 944 "ctrl F8", "resize", 945 "RIGHT", "right", 946 "KP_RIGHT", "right", 947 "shift RIGHT", "shrinkRight", 948 "shift KP_RIGHT", "shrinkRight", 949 "LEFT", "left", 950 "KP_LEFT", "left", 951 "shift LEFT", "shrinkLeft", 952 "shift KP_LEFT", "shrinkLeft", 953 "UP", "up", 954 "KP_UP", "up", 955 "shift UP", "shrinkUp", 956 "shift KP_UP", "shrinkUp", 957 "DOWN", "down", 958 "KP_DOWN", "down", 959 "shift DOWN", "shrinkDown", 960 "shift KP_DOWN", "shrinkDown", 961 "ESCAPE", "escape", 962 "ctrl F9", "minimize", 963 "ctrl F10", "maximize", 964 "ctrl F6", "selectNextFrame", 965 "ctrl TAB", "selectNextFrame", 966 "ctrl alt F6", "selectNextFrame", 967 "shift ctrl alt F6", "selectPreviousFrame", 968 "ctrl F12", "navigateNext", 969 "shift ctrl F12", "navigatePrevious" 970 }), 971 972 // *** Label 973 "Label.font", dialogPlain12, 974 "Label.background", control, 975 "Label.foreground", controlText, 976 "Label.disabledForeground", white, 977 "Label.disabledShadow", controlShadow, 978 "Label.border", null, 979 980 // *** List 981 "List.font", dialogPlain12, 982 "List.background", window, 983 "List.foreground", textText, 984 "List.selectionBackground", textHighlight, 985 "List.selectionForeground", textHighlightText, 986 "List.noFocusBorder", noFocusBorder, 987 "List.focusCellHighlightBorder", focusCellHighlightBorder, 988 "List.dropLineColor", controlShadow, 989 "List.border", null, 990 "List.cellRenderer", listCellRendererActiveValue, 991 "List.timeFactor", oneThousand, 992 "List.focusInputMap", 993 new UIDefaults.LazyInputMap(new Object[] { 994 "ctrl C", "copy", 995 "ctrl V", "paste", 996 "ctrl X", "cut", 997 "COPY", "copy", 998 "PASTE", "paste", 999 "CUT", "cut", 1000 "control INSERT", "copy", 1001 "shift INSERT", "paste", 1002 "shift DELETE", "cut", 1003 "UP", "selectPreviousRow", 1004 "KP_UP", "selectPreviousRow", 1005 "shift UP", "selectPreviousRowExtendSelection", 1006 "shift KP_UP", "selectPreviousRowExtendSelection", 1007 "ctrl shift UP", "selectPreviousRowExtendSelection", 1008 "ctrl shift KP_UP", "selectPreviousRowExtendSelection", 1009 "ctrl UP", "selectPreviousRowChangeLead", 1010 "ctrl KP_UP", "selectPreviousRowChangeLead", 1011 "DOWN", "selectNextRow", 1012 "KP_DOWN", "selectNextRow", 1013 "shift DOWN", "selectNextRowExtendSelection", 1014 "shift KP_DOWN", "selectNextRowExtendSelection", 1015 "ctrl shift DOWN", "selectNextRowExtendSelection", 1016 "ctrl shift KP_DOWN", "selectNextRowExtendSelection", 1017 "ctrl DOWN", "selectNextRowChangeLead", 1018 "ctrl KP_DOWN", "selectNextRowChangeLead", 1019 "LEFT", "selectPreviousColumn", 1020 "KP_LEFT", "selectPreviousColumn", 1021 "shift LEFT", "selectPreviousColumnExtendSelection", 1022 "shift KP_LEFT", "selectPreviousColumnExtendSelection", 1023 "ctrl shift LEFT", "selectPreviousColumnExtendSelection", 1024 "ctrl shift KP_LEFT", "selectPreviousColumnExtendSelection", 1025 "ctrl LEFT", "selectPreviousColumnChangeLead", 1026 "ctrl KP_LEFT", "selectPreviousColumnChangeLead", 1027 "RIGHT", "selectNextColumn", 1028 "KP_RIGHT", "selectNextColumn", 1029 "shift RIGHT", "selectNextColumnExtendSelection", 1030 "shift KP_RIGHT", "selectNextColumnExtendSelection", 1031 "ctrl shift RIGHT", "selectNextColumnExtendSelection", 1032 "ctrl shift KP_RIGHT", "selectNextColumnExtendSelection", 1033 "ctrl RIGHT", "selectNextColumnChangeLead", 1034 "ctrl KP_RIGHT", "selectNextColumnChangeLead", 1035 "HOME", "selectFirstRow", 1036 "shift HOME", "selectFirstRowExtendSelection", 1037 "ctrl shift HOME", "selectFirstRowExtendSelection", 1038 "ctrl HOME", "selectFirstRowChangeLead", 1039 "END", "selectLastRow", 1040 "shift END", "selectLastRowExtendSelection", 1041 "ctrl shift END", "selectLastRowExtendSelection", 1042 "ctrl END", "selectLastRowChangeLead", 1043 "PAGE_UP", "scrollUp", 1044 "shift PAGE_UP", "scrollUpExtendSelection", 1045 "ctrl shift PAGE_UP", "scrollUpExtendSelection", 1046 "ctrl PAGE_UP", "scrollUpChangeLead", 1047 "PAGE_DOWN", "scrollDown", 1048 "shift PAGE_DOWN", "scrollDownExtendSelection", 1049 "ctrl shift PAGE_DOWN", "scrollDownExtendSelection", 1050 "ctrl PAGE_DOWN", "scrollDownChangeLead", 1051 "ctrl A", "selectAll", 1052 "ctrl SLASH", "selectAll", 1053 "ctrl BACK_SLASH", "clearSelection", 1054 "SPACE", "addToSelection", 1055 "ctrl SPACE", "toggleAndAnchor", 1056 "shift SPACE", "extendTo", 1057 "ctrl shift SPACE", "moveSelectionTo" 1058 }), 1059 "List.focusInputMap.RightToLeft", 1060 new UIDefaults.LazyInputMap(new Object[] { 1061 "LEFT", "selectNextColumn", 1062 "KP_LEFT", "selectNextColumn", 1063 "shift LEFT", "selectNextColumnExtendSelection", 1064 "shift KP_LEFT", "selectNextColumnExtendSelection", 1065 "ctrl shift LEFT", "selectNextColumnExtendSelection", 1066 "ctrl shift KP_LEFT", "selectNextColumnExtendSelection", 1067 "ctrl LEFT", "selectNextColumnChangeLead", 1068 "ctrl KP_LEFT", "selectNextColumnChangeLead", 1069 "RIGHT", "selectPreviousColumn", 1070 "KP_RIGHT", "selectPreviousColumn", 1071 "shift RIGHT", "selectPreviousColumnExtendSelection", 1072 "shift KP_RIGHT", "selectPreviousColumnExtendSelection", 1073 "ctrl shift RIGHT", "selectPreviousColumnExtendSelection", 1074 "ctrl shift KP_RIGHT", "selectPreviousColumnExtendSelection", 1075 "ctrl RIGHT", "selectPreviousColumnChangeLead", 1076 "ctrl KP_RIGHT", "selectPreviousColumnChangeLead", 1077 }), 1078 1079 // *** Menus 1080 "MenuBar.font", dialogPlain12, 1081 "MenuBar.background", menu, 1082 "MenuBar.foreground", menuText, 1083 "MenuBar.shadow", controlShadow, 1084 "MenuBar.highlight", controlLtHighlight, 1085 "MenuBar.border", menuBarBorder, 1086 "MenuBar.windowBindings", new Object[] { 1087 "F10", "takeFocus" }, 1088 1089 "MenuItem.font", dialogPlain12, 1090 "MenuItem.acceleratorFont", dialogPlain12, 1091 "MenuItem.background", menu, 1092 "MenuItem.foreground", menuText, 1093 "MenuItem.selectionForeground", textHighlightText, 1094 "MenuItem.selectionBackground", textHighlight, 1095 "MenuItem.disabledForeground", null, 1096 "MenuItem.acceleratorForeground", menuText, 1097 "MenuItem.acceleratorSelectionForeground", textHighlightText, 1098 "MenuItem.acceleratorDelimiter", menuItemAcceleratorDelimiter, 1099 "MenuItem.border", marginBorder, 1100 "MenuItem.borderPainted", Boolean.FALSE, 1101 "MenuItem.margin", twoInsets, 1102 "MenuItem.checkIcon", menuItemCheckIcon, 1103 "MenuItem.arrowIcon", menuItemArrowIcon, 1104 "MenuItem.commandSound", null, 1105 1106 "RadioButtonMenuItem.font", dialogPlain12, 1107 "RadioButtonMenuItem.acceleratorFont", dialogPlain12, 1108 "RadioButtonMenuItem.background", menu, 1109 "RadioButtonMenuItem.foreground", menuText, 1110 "RadioButtonMenuItem.selectionForeground", textHighlightText, 1111 "RadioButtonMenuItem.selectionBackground", textHighlight, 1112 "RadioButtonMenuItem.disabledForeground", null, 1113 "RadioButtonMenuItem.acceleratorForeground", menuText, 1114 "RadioButtonMenuItem.acceleratorSelectionForeground", textHighlightText, 1115 "RadioButtonMenuItem.border", marginBorder, 1116 "RadioButtonMenuItem.borderPainted", Boolean.FALSE, 1117 "RadioButtonMenuItem.margin", twoInsets, 1118 "RadioButtonMenuItem.checkIcon", radioButtonMenuItemIcon, 1119 "RadioButtonMenuItem.arrowIcon", menuItemArrowIcon, 1120 "RadioButtonMenuItem.commandSound", null, 1121 1122 "CheckBoxMenuItem.font", dialogPlain12, 1123 "CheckBoxMenuItem.acceleratorFont", dialogPlain12, 1124 "CheckBoxMenuItem.background", menu, 1125 "CheckBoxMenuItem.foreground", menuText, 1126 "CheckBoxMenuItem.selectionForeground", textHighlightText, 1127 "CheckBoxMenuItem.selectionBackground", textHighlight, 1128 "CheckBoxMenuItem.disabledForeground", null, 1129 "CheckBoxMenuItem.acceleratorForeground", menuText, 1130 "CheckBoxMenuItem.acceleratorSelectionForeground", textHighlightText, 1131 "CheckBoxMenuItem.border", marginBorder, 1132 "CheckBoxMenuItem.borderPainted", Boolean.FALSE, 1133 "CheckBoxMenuItem.margin", twoInsets, 1134 "CheckBoxMenuItem.checkIcon", checkBoxMenuItemIcon, 1135 "CheckBoxMenuItem.arrowIcon", menuItemArrowIcon, 1136 "CheckBoxMenuItem.commandSound", null, 1137 1138 "Menu.font", dialogPlain12, 1139 "Menu.acceleratorFont", dialogPlain12, 1140 "Menu.background", menu, 1141 "Menu.foreground", menuText, 1142 "Menu.selectionForeground", textHighlightText, 1143 "Menu.selectionBackground", textHighlight, 1144 "Menu.disabledForeground", null, 1145 "Menu.acceleratorForeground", menuText, 1146 "Menu.acceleratorSelectionForeground", textHighlightText, 1147 "Menu.border", marginBorder, 1148 "Menu.borderPainted", Boolean.FALSE, 1149 "Menu.margin", twoInsets, 1150 "Menu.checkIcon", menuItemCheckIcon, 1151 "Menu.arrowIcon", menuArrowIcon, 1152 "Menu.menuPopupOffsetX", new Integer(0), 1153 "Menu.menuPopupOffsetY", new Integer(0), 1154 "Menu.submenuPopupOffsetX", new Integer(0), 1155 "Menu.submenuPopupOffsetY", new Integer(0), 1156 "Menu.shortcutKeys", new int[]{ 1157 SwingUtilities2.getSystemMnemonicKeyMask() 1158 }, 1159 "Menu.crossMenuMnemonic", Boolean.TRUE, 1160 // Menu.cancelMode affects the cancel menu action behaviour; 1161 // currently supports: 1162 // "hideLastSubmenu" (default) 1163 // hides the last open submenu, 1164 // and move selection one step back 1165 // "hideMenuTree" 1166 // resets selection and 1167 // hide the entire structure of open menu and its submenus 1168 "Menu.cancelMode", "hideLastSubmenu", 1169 1170 // Menu.preserveTopLevelSelection affects 1171 // the cancel menu action behaviour 1172 // if set to true then top level menu selection 1173 // will be preserved when the last popup was cancelled; 1174 // the menu itself will be unselect with the next cancel action 1175 "Menu.preserveTopLevelSelection", Boolean.FALSE, 1176 1177 // PopupMenu 1178 "PopupMenu.font", dialogPlain12, 1179 "PopupMenu.background", menu, 1180 "PopupMenu.foreground", menuText, 1181 "PopupMenu.border", popupMenuBorder, 1182 // Internal Frame Auditory Cue Mappings 1183 "PopupMenu.popupSound", null, 1184 // These window InputMap bindings are used when the Menu is 1185 // selected. 1186 "PopupMenu.selectedWindowInputMapBindings", new Object[] { 1187 "ESCAPE", "cancel", 1188 "DOWN", "selectNext", 1189 "KP_DOWN", "selectNext", 1190 "UP", "selectPrevious", 1191 "KP_UP", "selectPrevious", 1192 "LEFT", "selectParent", 1193 "KP_LEFT", "selectParent", 1194 "RIGHT", "selectChild", 1195 "KP_RIGHT", "selectChild", 1196 "ENTER", "return", 1197 "ctrl ENTER", "return", 1198 "SPACE", "return" 1199 }, 1200 "PopupMenu.selectedWindowInputMapBindings.RightToLeft", new Object[] { 1201 "LEFT", "selectChild", 1202 "KP_LEFT", "selectChild", 1203 "RIGHT", "selectParent", 1204 "KP_RIGHT", "selectParent", 1205 }, 1206 "PopupMenu.consumeEventOnClose", Boolean.FALSE, 1207 1208 // *** OptionPane 1209 // You can additionaly define OptionPane.messageFont which will 1210 // dictate the fonts used for the message, and 1211 // OptionPane.buttonFont, which defines the font for the buttons. 1212 "OptionPane.font", dialogPlain12, 1213 "OptionPane.background", control, 1214 "OptionPane.foreground", controlText, 1215 "OptionPane.messageForeground", controlText, 1216 "OptionPane.border", optionPaneBorder, 1217 "OptionPane.messageAreaBorder", zeroBorder, 1218 "OptionPane.buttonAreaBorder", optionPaneButtonAreaBorder, 1219 "OptionPane.minimumSize", optionPaneMinimumSize, 1220 "OptionPane.errorIcon", SwingUtilities2.makeIcon(getClass(), 1221 BasicLookAndFeel.class, 1222 "icons/Error.gif"), 1223 "OptionPane.informationIcon", SwingUtilities2.makeIcon(getClass(), 1224 BasicLookAndFeel.class, 1225 "icons/Inform.gif"), 1226 "OptionPane.warningIcon", SwingUtilities2.makeIcon(getClass(), 1227 BasicLookAndFeel.class, 1228 "icons/Warn.gif"), 1229 "OptionPane.questionIcon", SwingUtilities2.makeIcon(getClass(), 1230 BasicLookAndFeel.class, 1231 "icons/Question.gif"), 1232 "OptionPane.windowBindings", new Object[] { 1233 "ESCAPE", "close" }, 1234 // OptionPane Auditory Cue Mappings 1235 "OptionPane.errorSound", null, 1236 "OptionPane.informationSound", null, // Info and Plain 1237 "OptionPane.questionSound", null, 1238 "OptionPane.warningSound", null, 1239 "OptionPane.buttonClickThreshhold", fiveHundred, 1240 1241 // *** Panel 1242 "Panel.font", dialogPlain12, 1243 "Panel.background", control, 1244 "Panel.foreground", textText, 1245 1246 // *** ProgressBar 1247 "ProgressBar.font", dialogPlain12, 1248 "ProgressBar.foreground", textHighlight, 1249 "ProgressBar.background", control, 1250 "ProgressBar.selectionForeground", control, 1251 "ProgressBar.selectionBackground", textHighlight, 1252 "ProgressBar.border", progressBarBorder, 1253 "ProgressBar.cellLength", new Integer(1), 1254 "ProgressBar.cellSpacing", zero, 1255 "ProgressBar.repaintInterval", new Integer(50), 1256 "ProgressBar.cycleTime", new Integer(3000), 1257 "ProgressBar.horizontalSize", new DimensionUIResource(146, 12), 1258 "ProgressBar.verticalSize", new DimensionUIResource(12, 146), 1259 1260 // *** Separator 1261 "Separator.shadow", controlShadow, // DEPRECATED - DO NOT USE! 1262 "Separator.highlight", controlLtHighlight, // DEPRECATED - DO NOT USE! 1263 1264 "Separator.background", controlLtHighlight, 1265 "Separator.foreground", controlShadow, 1266 1267 // *** ScrollBar/ScrollPane/Viewport 1268 "ScrollBar.background", scrollBarTrack, 1269 "ScrollBar.foreground", control, 1270 "ScrollBar.track", table.get("scrollbar"), 1271 "ScrollBar.trackHighlight", controlDkShadow, 1272 "ScrollBar.thumb", control, 1273 "ScrollBar.thumbHighlight", controlLtHighlight, 1274 "ScrollBar.thumbDarkShadow", controlDkShadow, 1275 "ScrollBar.thumbShadow", controlShadow, 1276 "ScrollBar.border", null, 1277 "ScrollBar.minimumThumbSize", minimumThumbSize, 1278 "ScrollBar.maximumThumbSize", maximumThumbSize, 1279 "ScrollBar.ancestorInputMap", 1280 new UIDefaults.LazyInputMap(new Object[] { 1281 "RIGHT", "positiveUnitIncrement", 1282 "KP_RIGHT", "positiveUnitIncrement", 1283 "DOWN", "positiveUnitIncrement", 1284 "KP_DOWN", "positiveUnitIncrement", 1285 "PAGE_DOWN", "positiveBlockIncrement", 1286 "LEFT", "negativeUnitIncrement", 1287 "KP_LEFT", "negativeUnitIncrement", 1288 "UP", "negativeUnitIncrement", 1289 "KP_UP", "negativeUnitIncrement", 1290 "PAGE_UP", "negativeBlockIncrement", 1291 "HOME", "minScroll", 1292 "END", "maxScroll" 1293 }), 1294 "ScrollBar.ancestorInputMap.RightToLeft", 1295 new UIDefaults.LazyInputMap(new Object[] { 1296 "RIGHT", "negativeUnitIncrement", 1297 "KP_RIGHT", "negativeUnitIncrement", 1298 "LEFT", "positiveUnitIncrement", 1299 "KP_LEFT", "positiveUnitIncrement", 1300 }), 1301 "ScrollBar.width", new Integer(16), 1302 1303 "ScrollPane.font", dialogPlain12, 1304 "ScrollPane.background", control, 1305 "ScrollPane.foreground", controlText, 1306 "ScrollPane.border", textFieldBorder, 1307 "ScrollPane.viewportBorder", null, 1308 "ScrollPane.ancestorInputMap", 1309 new UIDefaults.LazyInputMap(new Object[] { 1310 "RIGHT", "unitScrollRight", 1311 "KP_RIGHT", "unitScrollRight", 1312 "DOWN", "unitScrollDown", 1313 "KP_DOWN", "unitScrollDown", 1314 "LEFT", "unitScrollLeft", 1315 "KP_LEFT", "unitScrollLeft", 1316 "UP", "unitScrollUp", 1317 "KP_UP", "unitScrollUp", 1318 "PAGE_UP", "scrollUp", 1319 "PAGE_DOWN", "scrollDown", 1320 "ctrl PAGE_UP", "scrollLeft", 1321 "ctrl PAGE_DOWN", "scrollRight", 1322 "ctrl HOME", "scrollHome", 1323 "ctrl END", "scrollEnd" 1324 }), 1325 "ScrollPane.ancestorInputMap.RightToLeft", 1326 new UIDefaults.LazyInputMap(new Object[] { 1327 "ctrl PAGE_UP", "scrollRight", 1328 "ctrl PAGE_DOWN", "scrollLeft", 1329 }), 1330 1331 "Viewport.font", dialogPlain12, 1332 "Viewport.background", control, 1333 "Viewport.foreground", textText, 1334 1335 // *** Slider 1336 "Slider.font", dialogPlain12, 1337 "Slider.foreground", control, 1338 "Slider.background", control, 1339 "Slider.highlight", controlLtHighlight, 1340 "Slider.tickColor", Color.black, 1341 "Slider.shadow", controlShadow, 1342 "Slider.focus", controlDkShadow, 1343 "Slider.border", null, 1344 "Slider.horizontalSize", new Dimension(200, 21), 1345 "Slider.verticalSize", new Dimension(21, 200), 1346 "Slider.minimumHorizontalSize", new Dimension(36, 21), 1347 "Slider.minimumVerticalSize", new Dimension(21, 36), 1348 "Slider.focusInsets", sliderFocusInsets, 1349 "Slider.focusInputMap", 1350 new UIDefaults.LazyInputMap(new Object[] { 1351 "RIGHT", "positiveUnitIncrement", 1352 "KP_RIGHT", "positiveUnitIncrement", 1353 "DOWN", "negativeUnitIncrement", 1354 "KP_DOWN", "negativeUnitIncrement", 1355 "PAGE_DOWN", "negativeBlockIncrement", 1356 "LEFT", "negativeUnitIncrement", 1357 "KP_LEFT", "negativeUnitIncrement", 1358 "UP", "positiveUnitIncrement", 1359 "KP_UP", "positiveUnitIncrement", 1360 "PAGE_UP", "positiveBlockIncrement", 1361 "HOME", "minScroll", 1362 "END", "maxScroll" 1363 }), 1364 "Slider.focusInputMap.RightToLeft", 1365 new UIDefaults.LazyInputMap(new Object[] { 1366 "RIGHT", "negativeUnitIncrement", 1367 "KP_RIGHT", "negativeUnitIncrement", 1368 "LEFT", "positiveUnitIncrement", 1369 "KP_LEFT", "positiveUnitIncrement", 1370 }), 1371 "Slider.onlyLeftMouseButtonDrag", Boolean.TRUE, 1372 1373 // *** Spinner 1374 "Spinner.font", monospacedPlain12, 1375 "Spinner.background", control, 1376 "Spinner.foreground", control, 1377 "Spinner.border", textFieldBorder, 1378 "Spinner.arrowButtonBorder", null, 1379 "Spinner.arrowButtonInsets", null, 1380 "Spinner.arrowButtonSize", new Dimension(16, 5), 1381 "Spinner.ancestorInputMap", 1382 new UIDefaults.LazyInputMap(new Object[] { 1383 "UP", "increment", 1384 "KP_UP", "increment", 1385 "DOWN", "decrement", 1386 "KP_DOWN", "decrement", 1387 }), 1388 "Spinner.editorBorderPainted", Boolean.FALSE, 1389 "Spinner.editorAlignment", JTextField.TRAILING, 1390 1391 // *** SplitPane 1392 "SplitPane.background", control, 1393 "SplitPane.highlight", controlLtHighlight, 1394 "SplitPane.shadow", controlShadow, 1395 "SplitPane.darkShadow", controlDkShadow, 1396 "SplitPane.border", splitPaneBorder, 1397 "SplitPane.dividerSize", new Integer(7), 1398 "SplitPaneDivider.border", splitPaneDividerBorder, 1399 "SplitPaneDivider.draggingColor", darkGray, 1400 "SplitPane.ancestorInputMap", 1401 new UIDefaults.LazyInputMap(new Object[] { 1402 "UP", "negativeIncrement", 1403 "DOWN", "positiveIncrement", 1404 "LEFT", "negativeIncrement", 1405 "RIGHT", "positiveIncrement", 1406 "KP_UP", "negativeIncrement", 1407 "KP_DOWN", "positiveIncrement", 1408 "KP_LEFT", "negativeIncrement", 1409 "KP_RIGHT", "positiveIncrement", 1410 "HOME", "selectMin", 1411 "END", "selectMax", 1412 "F8", "startResize", 1413 "F6", "toggleFocus", 1414 "ctrl TAB", "focusOutForward", 1415 "ctrl shift TAB", "focusOutBackward" 1416 }), 1417 1418 // *** TabbedPane 1419 "TabbedPane.font", dialogPlain12, 1420 "TabbedPane.background", control, 1421 "TabbedPane.foreground", controlText, 1422 "TabbedPane.highlight", controlLtHighlight, 1423 "TabbedPane.light", controlHighlight, 1424 "TabbedPane.shadow", controlShadow, 1425 "TabbedPane.darkShadow", controlDkShadow, 1426 "TabbedPane.selected", null, 1427 "TabbedPane.focus", controlText, 1428 "TabbedPane.textIconGap", four, 1429 1430 // Causes tabs to be painted on top of the content area border. 1431 // The amount of overlap is then controlled by tabAreaInsets.bottom, 1432 // which is zero by default 1433 "TabbedPane.tabsOverlapBorder", Boolean.FALSE, 1434 "TabbedPane.selectionFollowsFocus", Boolean.TRUE, 1435 1436 "TabbedPane.labelShift", 1, 1437 "TabbedPane.selectedLabelShift", -1, 1438 "TabbedPane.tabInsets", tabbedPaneTabInsets, 1439 "TabbedPane.selectedTabPadInsets", tabbedPaneTabPadInsets, 1440 "TabbedPane.tabAreaInsets", tabbedPaneTabAreaInsets, 1441 "TabbedPane.contentBorderInsets", tabbedPaneContentBorderInsets, 1442 "TabbedPane.tabRunOverlay", new Integer(2), 1443 "TabbedPane.tabsOpaque", Boolean.TRUE, 1444 "TabbedPane.contentOpaque", Boolean.TRUE, 1445 "TabbedPane.focusInputMap", 1446 new UIDefaults.LazyInputMap(new Object[] { 1447 "RIGHT", "navigateRight", 1448 "KP_RIGHT", "navigateRight", 1449 "LEFT", "navigateLeft", 1450 "KP_LEFT", "navigateLeft", 1451 "UP", "navigateUp", 1452 "KP_UP", "navigateUp", 1453 "DOWN", "navigateDown", 1454 "KP_DOWN", "navigateDown", 1455 "ctrl DOWN", "requestFocusForVisibleComponent", 1456 "ctrl KP_DOWN", "requestFocusForVisibleComponent", 1457 }), 1458 "TabbedPane.ancestorInputMap", 1459 new UIDefaults.LazyInputMap(new Object[] { 1460 "ctrl PAGE_DOWN", "navigatePageDown", 1461 "ctrl PAGE_UP", "navigatePageUp", 1462 "ctrl UP", "requestFocus", 1463 "ctrl KP_UP", "requestFocus", 1464 }), 1465 1466 1467 // *** Table 1468 "Table.font", dialogPlain12, 1469 "Table.foreground", controlText, // cell text color 1470 "Table.background", window, // cell background color 1471 "Table.selectionForeground", textHighlightText, 1472 "Table.selectionBackground", textHighlight, 1473 "Table.dropLineColor", controlShadow, 1474 "Table.dropLineShortColor", black, 1475 "Table.gridColor", gray, // grid line color 1476 "Table.focusCellBackground", window, 1477 "Table.focusCellForeground", controlText, 1478 "Table.focusCellHighlightBorder", focusCellHighlightBorder, 1479 "Table.scrollPaneBorder", loweredBevelBorder, 1480 "Table.ancestorInputMap", 1481 new UIDefaults.LazyInputMap(new Object[] { 1482 "ctrl C", "copy", 1483 "ctrl V", "paste", 1484 "ctrl X", "cut", 1485 "COPY", "copy", 1486 "PASTE", "paste", 1487 "CUT", "cut", 1488 "control INSERT", "copy", 1489 "shift INSERT", "paste", 1490 "shift DELETE", "cut", 1491 "RIGHT", "selectNextColumn", 1492 "KP_RIGHT", "selectNextColumn", 1493 "shift RIGHT", "selectNextColumnExtendSelection", 1494 "shift KP_RIGHT", "selectNextColumnExtendSelection", 1495 "ctrl shift RIGHT", "selectNextColumnExtendSelection", 1496 "ctrl shift KP_RIGHT", "selectNextColumnExtendSelection", 1497 "ctrl RIGHT", "selectNextColumnChangeLead", 1498 "ctrl KP_RIGHT", "selectNextColumnChangeLead", 1499 "LEFT", "selectPreviousColumn", 1500 "KP_LEFT", "selectPreviousColumn", 1501 "shift LEFT", "selectPreviousColumnExtendSelection", 1502 "shift KP_LEFT", "selectPreviousColumnExtendSelection", 1503 "ctrl shift LEFT", "selectPreviousColumnExtendSelection", 1504 "ctrl shift KP_LEFT", "selectPreviousColumnExtendSelection", 1505 "ctrl LEFT", "selectPreviousColumnChangeLead", 1506 "ctrl KP_LEFT", "selectPreviousColumnChangeLead", 1507 "DOWN", "selectNextRow", 1508 "KP_DOWN", "selectNextRow", 1509 "shift DOWN", "selectNextRowExtendSelection", 1510 "shift KP_DOWN", "selectNextRowExtendSelection", 1511 "ctrl shift DOWN", "selectNextRowExtendSelection", 1512 "ctrl shift KP_DOWN", "selectNextRowExtendSelection", 1513 "ctrl DOWN", "selectNextRowChangeLead", 1514 "ctrl KP_DOWN", "selectNextRowChangeLead", 1515 "UP", "selectPreviousRow", 1516 "KP_UP", "selectPreviousRow", 1517 "shift UP", "selectPreviousRowExtendSelection", 1518 "shift KP_UP", "selectPreviousRowExtendSelection", 1519 "ctrl shift UP", "selectPreviousRowExtendSelection", 1520 "ctrl shift KP_UP", "selectPreviousRowExtendSelection", 1521 "ctrl UP", "selectPreviousRowChangeLead", 1522 "ctrl KP_UP", "selectPreviousRowChangeLead", 1523 "HOME", "selectFirstColumn", 1524 "shift HOME", "selectFirstColumnExtendSelection", 1525 "ctrl shift HOME", "selectFirstRowExtendSelection", 1526 "ctrl HOME", "selectFirstRow", 1527 "END", "selectLastColumn", 1528 "shift END", "selectLastColumnExtendSelection", 1529 "ctrl shift END", "selectLastRowExtendSelection", 1530 "ctrl END", "selectLastRow", 1531 "PAGE_UP", "scrollUpChangeSelection", 1532 "shift PAGE_UP", "scrollUpExtendSelection", 1533 "ctrl shift PAGE_UP", "scrollLeftExtendSelection", 1534 "ctrl PAGE_UP", "scrollLeftChangeSelection", 1535 "PAGE_DOWN", "scrollDownChangeSelection", 1536 "shift PAGE_DOWN", "scrollDownExtendSelection", 1537 "ctrl shift PAGE_DOWN", "scrollRightExtendSelection", 1538 "ctrl PAGE_DOWN", "scrollRightChangeSelection", 1539 "TAB", "selectNextColumnCell", 1540 "shift TAB", "selectPreviousColumnCell", 1541 "ENTER", "selectNextRowCell", 1542 "shift ENTER", "selectPreviousRowCell", 1543 "ctrl A", "selectAll", 1544 "ctrl SLASH", "selectAll", 1545 "ctrl BACK_SLASH", "clearSelection", 1546 "ESCAPE", "cancel", 1547 "F2", "startEditing", 1548 "SPACE", "addToSelection", 1549 "ctrl SPACE", "toggleAndAnchor", 1550 "shift SPACE", "extendTo", 1551 "ctrl shift SPACE", "moveSelectionTo", 1552 "F8", "focusHeader" 1553 }), 1554 "Table.ancestorInputMap.RightToLeft", 1555 new UIDefaults.LazyInputMap(new Object[] { 1556 "RIGHT", "selectPreviousColumn", 1557 "KP_RIGHT", "selectPreviousColumn", 1558 "shift RIGHT", "selectPreviousColumnExtendSelection", 1559 "shift KP_RIGHT", "selectPreviousColumnExtendSelection", 1560 "ctrl shift RIGHT", "selectPreviousColumnExtendSelection", 1561 "ctrl shift KP_RIGHT", "selectPreviousColumnExtendSelection", 1562 "ctrl RIGHT", "selectPreviousColumnChangeLead", 1563 "ctrl KP_RIGHT", "selectPreviousColumnChangeLead", 1564 "LEFT", "selectNextColumn", 1565 "KP_LEFT", "selectNextColumn", 1566 "shift LEFT", "selectNextColumnExtendSelection", 1567 "shift KP_LEFT", "selectNextColumnExtendSelection", 1568 "ctrl shift LEFT", "selectNextColumnExtendSelection", 1569 "ctrl shift KP_LEFT", "selectNextColumnExtendSelection", 1570 "ctrl LEFT", "selectNextColumnChangeLead", 1571 "ctrl KP_LEFT", "selectNextColumnChangeLead", 1572 "ctrl PAGE_UP", "scrollRightChangeSelection", 1573 "ctrl PAGE_DOWN", "scrollLeftChangeSelection", 1574 "ctrl shift PAGE_UP", "scrollRightExtendSelection", 1575 "ctrl shift PAGE_DOWN", "scrollLeftExtendSelection", 1576 }), 1577 "Table.ascendingSortIcon", new SwingLazyValue( 1578 "sun.swing.icon.SortArrowIcon", 1579 null, new Object[] { Boolean.TRUE, 1580 "Table.sortIconColor" }), 1581 "Table.descendingSortIcon", new SwingLazyValue( 1582 "sun.swing.icon.SortArrowIcon", 1583 null, new Object[] { Boolean.FALSE, 1584 "Table.sortIconColor" }), 1585 "Table.sortIconColor", controlShadow, 1586 1587 "TableHeader.font", dialogPlain12, 1588 "TableHeader.foreground", controlText, // header text color 1589 "TableHeader.background", control, // header background 1590 "TableHeader.cellBorder", tableHeaderBorder, 1591 1592 // Support for changing the background/border of the currently 1593 // selected header column when the header has the keyboard focus. 1594 "TableHeader.focusCellBackground", table.getColor("text"), // like text component bg 1595 "TableHeader.focusCellForeground", null, 1596 "TableHeader.focusCellBorder", null, 1597 "TableHeader.ancestorInputMap", 1598 new UIDefaults.LazyInputMap(new Object[] { 1599 "SPACE", "toggleSortOrder", 1600 "LEFT", "selectColumnToLeft", 1601 "KP_LEFT", "selectColumnToLeft", 1602 "RIGHT", "selectColumnToRight", 1603 "KP_RIGHT", "selectColumnToRight", 1604 "alt LEFT", "moveColumnLeft", 1605 "alt KP_LEFT", "moveColumnLeft", 1606 "alt RIGHT", "moveColumnRight", 1607 "alt KP_RIGHT", "moveColumnRight", 1608 "alt shift LEFT", "resizeLeft", 1609 "alt shift KP_LEFT", "resizeLeft", 1610 "alt shift RIGHT", "resizeRight", 1611 "alt shift KP_RIGHT", "resizeRight", 1612 "ESCAPE", "focusTable", 1613 }), 1614 1615 // *** Text 1616 "TextField.font", sansSerifPlain12, 1617 "TextField.background", window, 1618 "TextField.foreground", textText, 1619 "TextField.shadow", controlShadow, 1620 "TextField.darkShadow", controlDkShadow, 1621 "TextField.light", controlHighlight, 1622 "TextField.highlight", controlLtHighlight, 1623 "TextField.inactiveForeground", textInactiveText, 1624 "TextField.inactiveBackground", control, 1625 "TextField.selectionBackground", textHighlight, 1626 "TextField.selectionForeground", textHighlightText, 1627 "TextField.caretForeground", textText, 1628 "TextField.caretBlinkRate", caretBlinkRate, 1629 "TextField.border", textFieldBorder, 1630 "TextField.margin", zeroInsets, 1631 1632 "FormattedTextField.font", sansSerifPlain12, 1633 "FormattedTextField.background", window, 1634 "FormattedTextField.foreground", textText, 1635 "FormattedTextField.inactiveForeground", textInactiveText, 1636 "FormattedTextField.inactiveBackground", control, 1637 "FormattedTextField.selectionBackground", textHighlight, 1638 "FormattedTextField.selectionForeground", textHighlightText, 1639 "FormattedTextField.caretForeground", textText, 1640 "FormattedTextField.caretBlinkRate", caretBlinkRate, 1641 "FormattedTextField.border", textFieldBorder, 1642 "FormattedTextField.margin", zeroInsets, 1643 "FormattedTextField.focusInputMap", 1644 new UIDefaults.LazyInputMap(new Object[] { 1645 "ctrl C", DefaultEditorKit.copyAction, 1646 "ctrl V", DefaultEditorKit.pasteAction, 1647 "ctrl X", DefaultEditorKit.cutAction, 1648 "COPY", DefaultEditorKit.copyAction, 1649 "PASTE", DefaultEditorKit.pasteAction, 1650 "CUT", DefaultEditorKit.cutAction, 1651 "control INSERT", DefaultEditorKit.copyAction, 1652 "shift INSERT", DefaultEditorKit.pasteAction, 1653 "shift DELETE", DefaultEditorKit.cutAction, 1654 "shift LEFT", DefaultEditorKit.selectionBackwardAction, 1655 "shift KP_LEFT", DefaultEditorKit.selectionBackwardAction, 1656 "shift RIGHT", DefaultEditorKit.selectionForwardAction, 1657 "shift KP_RIGHT", DefaultEditorKit.selectionForwardAction, 1658 "ctrl LEFT", DefaultEditorKit.previousWordAction, 1659 "ctrl KP_LEFT", DefaultEditorKit.previousWordAction, 1660 "ctrl RIGHT", DefaultEditorKit.nextWordAction, 1661 "ctrl KP_RIGHT", DefaultEditorKit.nextWordAction, 1662 "ctrl shift LEFT", DefaultEditorKit.selectionPreviousWordAction, 1663 "ctrl shift KP_LEFT", DefaultEditorKit.selectionPreviousWordAction, 1664 "ctrl shift RIGHT", DefaultEditorKit.selectionNextWordAction, 1665 "ctrl shift KP_RIGHT", DefaultEditorKit.selectionNextWordAction, 1666 "ctrl A", DefaultEditorKit.selectAllAction, 1667 "HOME", DefaultEditorKit.beginLineAction, 1668 "END", DefaultEditorKit.endLineAction, 1669 "shift HOME", DefaultEditorKit.selectionBeginLineAction, 1670 "shift END", DefaultEditorKit.selectionEndLineAction, 1671 "BACK_SPACE", DefaultEditorKit.deletePrevCharAction, 1672 "shift BACK_SPACE", DefaultEditorKit.deletePrevCharAction, 1673 "ctrl H", DefaultEditorKit.deletePrevCharAction, 1674 "DELETE", DefaultEditorKit.deleteNextCharAction, 1675 "ctrl DELETE", DefaultEditorKit.deleteNextWordAction, 1676 "ctrl BACK_SPACE", DefaultEditorKit.deletePrevWordAction, 1677 "RIGHT", DefaultEditorKit.forwardAction, 1678 "LEFT", DefaultEditorKit.backwardAction, 1679 "KP_RIGHT", DefaultEditorKit.forwardAction, 1680 "KP_LEFT", DefaultEditorKit.backwardAction, 1681 "ENTER", JTextField.notifyAction, 1682 "ctrl BACK_SLASH", "unselect", 1683 "control shift O", "toggle-componentOrientation", 1684 "ESCAPE", "reset-field-edit", 1685 "UP", "increment", 1686 "KP_UP", "increment", 1687 "DOWN", "decrement", 1688 "KP_DOWN", "decrement", 1689 }), 1690 1691 "PasswordField.font", monospacedPlain12, 1692 "PasswordField.background", window, 1693 "PasswordField.foreground", textText, 1694 "PasswordField.inactiveForeground", textInactiveText, 1695 "PasswordField.inactiveBackground", control, 1696 "PasswordField.selectionBackground", textHighlight, 1697 "PasswordField.selectionForeground", textHighlightText, 1698 "PasswordField.caretForeground", textText, 1699 "PasswordField.caretBlinkRate", caretBlinkRate, 1700 "PasswordField.border", textFieldBorder, 1701 "PasswordField.margin", zeroInsets, 1702 "PasswordField.echoChar", '*', 1703 1704 "TextArea.font", monospacedPlain12, 1705 "TextArea.background", window, 1706 "TextArea.foreground", textText, 1707 "TextArea.inactiveForeground", textInactiveText, 1708 "TextArea.selectionBackground", textHighlight, 1709 "TextArea.selectionForeground", textHighlightText, 1710 "TextArea.caretForeground", textText, 1711 "TextArea.caretBlinkRate", caretBlinkRate, 1712 "TextArea.border", marginBorder, 1713 "TextArea.margin", zeroInsets, 1714 1715 "TextPane.font", serifPlain12, 1716 "TextPane.background", white, 1717 "TextPane.foreground", textText, 1718 "TextPane.selectionBackground", textHighlight, 1719 "TextPane.selectionForeground", textHighlightText, 1720 "TextPane.caretForeground", textText, 1721 "TextPane.caretBlinkRate", caretBlinkRate, 1722 "TextPane.inactiveForeground", textInactiveText, 1723 "TextPane.border", marginBorder, 1724 "TextPane.margin", editorMargin, 1725 1726 "EditorPane.font", serifPlain12, 1727 "EditorPane.background", white, 1728 "EditorPane.foreground", textText, 1729 "EditorPane.selectionBackground", textHighlight, 1730 "EditorPane.selectionForeground", textHighlightText, 1731 "EditorPane.caretForeground", textText, 1732 "EditorPane.caretBlinkRate", caretBlinkRate, 1733 "EditorPane.inactiveForeground", textInactiveText, 1734 "EditorPane.border", marginBorder, 1735 "EditorPane.margin", editorMargin, 1736 1737 "html.pendingImage", SwingUtilities2.makeIcon(getClass(), 1738 BasicLookAndFeel.class, 1739 "icons/image-delayed.png"), 1740 "html.missingImage", SwingUtilities2.makeIcon(getClass(), 1741 BasicLookAndFeel.class, 1742 "icons/image-failed.png"), 1743 // *** TitledBorder 1744 "TitledBorder.font", dialogPlain12, 1745 "TitledBorder.titleColor", controlText, 1746 "TitledBorder.border", etchedBorder, 1747 1748 // *** ToolBar 1749 "ToolBar.font", dialogPlain12, 1750 "ToolBar.background", control, 1751 "ToolBar.foreground", controlText, 1752 "ToolBar.shadow", controlShadow, 1753 "ToolBar.darkShadow", controlDkShadow, 1754 "ToolBar.light", controlHighlight, 1755 "ToolBar.highlight", controlLtHighlight, 1756 "ToolBar.dockingBackground", control, 1757 "ToolBar.dockingForeground", red, 1758 "ToolBar.floatingBackground", control, 1759 "ToolBar.floatingForeground", darkGray, 1760 "ToolBar.border", etchedBorder, 1761 "ToolBar.separatorSize", toolBarSeparatorSize, 1762 "ToolBar.ancestorInputMap", 1763 new UIDefaults.LazyInputMap(new Object[] { 1764 "UP", "navigateUp", 1765 "KP_UP", "navigateUp", 1766 "DOWN", "navigateDown", 1767 "KP_DOWN", "navigateDown", 1768 "LEFT", "navigateLeft", 1769 "KP_LEFT", "navigateLeft", 1770 "RIGHT", "navigateRight", 1771 "KP_RIGHT", "navigateRight" 1772 }), 1773 1774 // *** ToolTips 1775 "ToolTip.font", sansSerifPlain12, 1776 "ToolTip.background", table.get("info"), 1777 "ToolTip.foreground", table.get("infoText"), 1778 "ToolTip.border", blackLineBorder, 1779 // ToolTips also support backgroundInactive, borderInactive, 1780 // and foregroundInactive 1781 1782 // *** ToolTipManager 1783 // ToolTipManager.enableToolTipMode currently supports: 1784 // "allWindows" (default): 1785 // enables tool tips for all windows of all java applications, 1786 // whether the windows are active or inactive 1787 // "activeApplication" 1788 // enables tool tips for windows of an application only when 1789 // the application has an active window 1790 "ToolTipManager.enableToolTipMode", "allWindows", 1791 1792 // *** Tree 1793 "Tree.paintLines", Boolean.TRUE, 1794 "Tree.lineTypeDashed", Boolean.FALSE, 1795 "Tree.font", dialogPlain12, 1796 "Tree.background", window, 1797 "Tree.foreground", textText, 1798 "Tree.hash", gray, 1799 "Tree.textForeground", textText, 1800 "Tree.textBackground", table.get("text"), 1801 "Tree.selectionForeground", textHighlightText, 1802 "Tree.selectionBackground", textHighlight, 1803 "Tree.selectionBorderColor", black, 1804 "Tree.dropLineColor", controlShadow, 1805 "Tree.editorBorder", blackLineBorder, 1806 "Tree.leftChildIndent", new Integer(7), 1807 "Tree.rightChildIndent", new Integer(13), 1808 "Tree.rowHeight", new Integer(16), 1809 "Tree.scrollsOnExpand", Boolean.TRUE, 1810 "Tree.openIcon", SwingUtilities2.makeIcon(getClass(), 1811 BasicLookAndFeel.class, 1812 "icons/TreeOpen.gif"), 1813 "Tree.closedIcon", SwingUtilities2.makeIcon(getClass(), 1814 BasicLookAndFeel.class, 1815 "icons/TreeClosed.gif"), 1816 "Tree.leafIcon", SwingUtilities2.makeIcon(getClass(), 1817 BasicLookAndFeel.class, 1818 "icons/TreeLeaf.gif"), 1819 "Tree.expandedIcon", null, 1820 "Tree.collapsedIcon", null, 1821 "Tree.changeSelectionWithFocus", Boolean.TRUE, 1822 "Tree.drawsFocusBorderAroundIcon", Boolean.FALSE, 1823 "Tree.timeFactor", oneThousand, 1824 "Tree.focusInputMap", 1825 new UIDefaults.LazyInputMap(new Object[] { 1826 "ctrl C", "copy", 1827 "ctrl V", "paste", 1828 "ctrl X", "cut", 1829 "COPY", "copy", 1830 "PASTE", "paste", 1831 "CUT", "cut", 1832 "control INSERT", "copy", 1833 "shift INSERT", "paste", 1834 "shift DELETE", "cut", 1835 "UP", "selectPrevious", 1836 "KP_UP", "selectPrevious", 1837 "shift UP", "selectPreviousExtendSelection", 1838 "shift KP_UP", "selectPreviousExtendSelection", 1839 "ctrl shift UP", "selectPreviousExtendSelection", 1840 "ctrl shift KP_UP", "selectPreviousExtendSelection", 1841 "ctrl UP", "selectPreviousChangeLead", 1842 "ctrl KP_UP", "selectPreviousChangeLead", 1843 "DOWN", "selectNext", 1844 "KP_DOWN", "selectNext", 1845 "shift DOWN", "selectNextExtendSelection", 1846 "shift KP_DOWN", "selectNextExtendSelection", 1847 "ctrl shift DOWN", "selectNextExtendSelection", 1848 "ctrl shift KP_DOWN", "selectNextExtendSelection", 1849 "ctrl DOWN", "selectNextChangeLead", 1850 "ctrl KP_DOWN", "selectNextChangeLead", 1851 "RIGHT", "selectChild", 1852 "KP_RIGHT", "selectChild", 1853 "LEFT", "selectParent", 1854 "KP_LEFT", "selectParent", 1855 "PAGE_UP", "scrollUpChangeSelection", 1856 "shift PAGE_UP", "scrollUpExtendSelection", 1857 "ctrl shift PAGE_UP", "scrollUpExtendSelection", 1858 "ctrl PAGE_UP", "scrollUpChangeLead", 1859 "PAGE_DOWN", "scrollDownChangeSelection", 1860 "shift PAGE_DOWN", "scrollDownExtendSelection", 1861 "ctrl shift PAGE_DOWN", "scrollDownExtendSelection", 1862 "ctrl PAGE_DOWN", "scrollDownChangeLead", 1863 "HOME", "selectFirst", 1864 "shift HOME", "selectFirstExtendSelection", 1865 "ctrl shift HOME", "selectFirstExtendSelection", 1866 "ctrl HOME", "selectFirstChangeLead", 1867 "END", "selectLast", 1868 "shift END", "selectLastExtendSelection", 1869 "ctrl shift END", "selectLastExtendSelection", 1870 "ctrl END", "selectLastChangeLead", 1871 "F2", "startEditing", 1872 "ctrl A", "selectAll", 1873 "ctrl SLASH", "selectAll", 1874 "ctrl BACK_SLASH", "clearSelection", 1875 "ctrl LEFT", "scrollLeft", 1876 "ctrl KP_LEFT", "scrollLeft", 1877 "ctrl RIGHT", "scrollRight", 1878 "ctrl KP_RIGHT", "scrollRight", 1879 "SPACE", "addToSelection", 1880 "ctrl SPACE", "toggleAndAnchor", 1881 "shift SPACE", "extendTo", 1882 "ctrl shift SPACE", "moveSelectionTo" 1883 }), 1884 "Tree.focusInputMap.RightToLeft", 1885 new UIDefaults.LazyInputMap(new Object[] { 1886 "RIGHT", "selectParent", 1887 "KP_RIGHT", "selectParent", 1888 "LEFT", "selectChild", 1889 "KP_LEFT", "selectChild", 1890 }), 1891 "Tree.ancestorInputMap", 1892 new UIDefaults.LazyInputMap(new Object[] { 1893 "ESCAPE", "cancel" 1894 }), 1895 // Bind specific keys that can invoke popup on currently 1896 // focused JComponent 1897 "RootPane.ancestorInputMap", 1898 new UIDefaults.LazyInputMap(new Object[] { 1899 "shift F10", "postPopup", 1900 "CONTEXT_MENU", "postPopup" 1901 }), 1902 1903 // These bindings are only enabled when there is a default 1904 // button set on the rootpane. 1905 "RootPane.defaultButtonWindowKeyBindings", new Object[] { 1906 "ENTER", "press", 1907 "released ENTER", "release", 1908 "ctrl ENTER", "press", 1909 "ctrl released ENTER", "release" 1910 }, 1911 }; 1912 1913 table.putDefaults(defaults); 1914 } 1915 1916 static int getFocusAcceleratorKeyMask() { 1917 Toolkit tk = Toolkit.getDefaultToolkit(); 1918 if (tk instanceof SunToolkit) { 1919 return ((SunToolkit)tk).getFocusAcceleratorKeyMask(); 1920 } 1921 return ActionEvent.ALT_MASK; 1922 } 1923 1924 1925 1926 /** 1927 * Returns the ui that is of type <code>klass</code>, or null if 1928 * one can not be found. 1929 */ 1930 static Object getUIOfType(ComponentUI ui, Class klass) { 1931 if (klass.isInstance(ui)) { 1932 return ui; 1933 } 1934 return null; 1935 } 1936 1937 // ********* Auditory Cue support methods and objects ********* 1938 // also see the "AuditoryCues" section of the defaults table 1939 1940 /** 1941 * Returns an <code>ActionMap</code> containing the audio actions 1942 * for this look and feel. 1943 * <P> 1944 * The returned <code>ActionMap</code> contains <code>Actions</code> that 1945 * embody the ability to render an auditory cue. These auditory 1946 * cues map onto user and system activities that may be useful 1947 * for an end user to know about (such as a dialog box appearing). 1948 * <P> 1949 * At the appropriate time, 1950 * the {@code ComponentUI} is responsible for obtaining an 1951 * <code>Action</code> out of the <code>ActionMap</code> and passing 1952 * it to <code>playSound</code>. 1953 * <P> 1954 * This method first looks up the {@code ActionMap} from the 1955 * defaults using the key {@code "AuditoryCues.actionMap"}. 1956 * <p> 1957 * If the value is {@code non-null}, it is returned. If the value 1958 * of the default {@code "AuditoryCues.actionMap"} is {@code null} 1959 * and the value of the default {@code "AuditoryCues.cueList"} is 1960 * {@code non-null}, an {@code ActionMapUIResource} is created and 1961 * populated. Population is done by iterating over each of the 1962 * elements of the {@code "AuditoryCues.cueList"} array, and 1963 * invoking {@code createAudioAction()} to create an {@code 1964 * Action} for each element. The resulting {@code Action} is 1965 * placed in the {@code ActionMapUIResource}, using the array 1966 * element as the key. For example, if the {@code 1967 * "AuditoryCues.cueList"} array contains a single-element, {@code 1968 * "audioKey"}, the {@code ActionMapUIResource} is created, then 1969 * populated by way of {@code actionMap.put(cueList[0], 1970 * createAudioAction(cueList[0]))}. 1971 * <p> 1972 * If the value of the default {@code "AuditoryCues.actionMap"} is 1973 * {@code null} and the value of the default 1974 * {@code "AuditoryCues.cueList"} is {@code null}, an empty 1975 * {@code ActionMapUIResource} is created. 1976 * 1977 * 1978 * @return an ActionMap containing {@code Actions} 1979 * responsible for playing auditory cues 1980 * @throws ClassCastException if the value of the 1981 * default {@code "AuditoryCues.actionMap"} is not an 1982 * {@code ActionMap}, or the value of the default 1983 * {@code "AuditoryCues.cueList"} is not an {@code Object[]} 1984 * @see #createAudioAction 1985 * @see #playSound(Action) 1986 * @since 1.4 1987 */ 1988 protected ActionMap getAudioActionMap() { 1989 ActionMap audioActionMap = (ActionMap)UIManager.get( 1990 "AuditoryCues.actionMap"); 1991 if (audioActionMap == null) { 1992 Object[] acList = (Object[])UIManager.get("AuditoryCues.cueList"); 1993 if (acList != null) { 1994 audioActionMap = new ActionMapUIResource(); 1995 for(int counter = acList.length-1; counter >= 0; counter--) { 1996 audioActionMap.put(acList[counter], 1997 createAudioAction(acList[counter])); 1998 } 1999 } 2000 UIManager.getLookAndFeelDefaults().put("AuditoryCues.actionMap", 2001 audioActionMap); 2002 } 2003 return audioActionMap; 2004 } 2005 2006 /** 2007 * Creates and returns an {@code Action} used to play a sound. 2008 * <p> 2009 * If {@code key} is {@code non-null}, an {@code Action} is created 2010 * using the value from the defaults with key {@code key}. The value 2011 * identifies the sound resource to load when 2012 * {@code actionPerformed} is invoked on the {@code Action}. The 2013 * sound resource is loaded into a {@code byte[]} by way of 2014 * {@code getClass().getResourceAsStream()}. 2015 * 2016 * @param key the key identifying the audio action 2017 * @return an {@code Action} used to play the source, or {@code null} 2018 * if {@code key} is {@code null} 2019 * @see #playSound(Action) 2020 * @since 1.4 2021 */ 2022 protected Action createAudioAction(Object key) { 2023 if (key != null) { 2024 String audioKey = (String)key; 2025 String audioValue = (String)UIManager.get(key); 2026 return new AudioAction(audioKey, audioValue); 2027 } else { 2028 return null; 2029 } 2030 } 2031 2032 /** 2033 * Pass the name String to the super constructor. This is used 2034 * later to identify the Action and decide whether to play it or 2035 * not. Store the resource String. I is used to get the audio 2036 * resource. In this case, the resource is an audio file. 2037 * 2038 * @since 1.4 2039 */ 2040 private class AudioAction extends AbstractAction implements LineListener { 2041 // We strive to only play one sound at a time (other platforms 2042 // appear to do this). This is done by maintaining the field 2043 // clipPlaying. Every time a sound is to be played, 2044 // cancelCurrentSound is invoked to cancel any sound that may be 2045 // playing. 2046 private String audioResource; 2047 private byte[] audioBuffer; 2048 2049 /** 2050 * The String is the name of the Action and 2051 * points to the audio resource. 2052 * The byte[] is a buffer of the audio bits. 2053 */ 2054 public AudioAction(String name, String resource) { 2055 super(name); 2056 audioResource = resource; 2057 } 2058 2059 public void actionPerformed(ActionEvent e) { 2060 if (audioBuffer == null) { 2061 audioBuffer = loadAudioData(audioResource); 2062 } 2063 if (audioBuffer != null) { 2064 cancelCurrentSound(null); 2065 try { 2066 AudioInputStream soundStream = 2067 AudioSystem.getAudioInputStream( 2068 new ByteArrayInputStream(audioBuffer)); 2069 DataLine.Info info = 2070 new DataLine.Info(Clip.class, soundStream.getFormat()); 2071 Clip clip = (Clip) AudioSystem.getLine(info); 2072 clip.open(soundStream); 2073 clip.addLineListener(this); 2074 2075 synchronized(audioLock) { 2076 clipPlaying = clip; 2077 } 2078 2079 clip.start(); 2080 } catch (Exception ex) {} 2081 } 2082 } 2083 2084 public void update(LineEvent event) { 2085 if (event.getType() == LineEvent.Type.STOP) { 2086 cancelCurrentSound((Clip)event.getLine()); 2087 } 2088 } 2089 2090 /** 2091 * If the parameter is null, or equal to the currently 2092 * playing sound, then cancel the currently playing sound. 2093 */ 2094 private void cancelCurrentSound(Clip clip) { 2095 Clip lastClip = null; 2096 2097 synchronized(audioLock) { 2098 if (clip == null || clip == clipPlaying) { 2099 lastClip = clipPlaying; 2100 clipPlaying = null; 2101 } 2102 } 2103 2104 if (lastClip != null) { 2105 lastClip.removeLineListener(this); 2106 lastClip.close(); 2107 } 2108 } 2109 } 2110 2111 /** 2112 * Utility method that loads audio bits for the specified 2113 * <code>soundFile</code> filename. If this method is unable to 2114 * build a viable path name from the <code>baseClass</code> and 2115 * <code>soundFile</code> passed into this method, it will 2116 * return <code>null</code>. 2117 * 2118 * @param soundFile the name of the audio file to be retrieved 2119 * from disk 2120 * @return A byte[] with audio data or null 2121 * @since 1.4 2122 */ 2123 private byte[] loadAudioData(final String soundFile){ 2124 if (soundFile == null) { 2125 return null; 2126 } 2127 /* Copy resource into a byte array. This is 2128 * necessary because several browsers consider 2129 * Class.getResource a security risk since it 2130 * can be used to load additional classes. 2131 * Class.getResourceAsStream just returns raw 2132 * bytes, which we can convert to a sound. 2133 */ 2134 byte[] buffer = AccessController.doPrivileged( 2135 new PrivilegedAction<byte[]>() { 2136 public byte[] run() { 2137 try { 2138 InputStream resource = BasicLookAndFeel.this. 2139 getClass().getResourceAsStream(soundFile); 2140 if (resource == null) { 2141 return null; 2142 } 2143 BufferedInputStream in = 2144 new BufferedInputStream(resource); 2145 ByteArrayOutputStream out = 2146 new ByteArrayOutputStream(1024); 2147 byte[] buffer = new byte[1024]; 2148 int n; 2149 while ((n = in.read(buffer)) > 0) { 2150 out.write(buffer, 0, n); 2151 } 2152 in.close(); 2153 out.flush(); 2154 buffer = out.toByteArray(); 2155 return buffer; 2156 } catch (IOException ioe) { 2157 System.err.println(ioe.toString()); 2158 return null; 2159 } 2160 } 2161 }); 2162 if (buffer == null) { 2163 System.err.println(getClass().getName() + "/" + 2164 soundFile + " not found."); 2165 return null; 2166 } 2167 if (buffer.length == 0) { 2168 System.err.println("warning: " + soundFile + 2169 " is zero-length"); 2170 return null; 2171 } 2172 return buffer; 2173 } 2174 2175 /** 2176 * If necessary, invokes {@code actionPerformed} on 2177 * {@code audioAction} to play a sound. 2178 * The {@code actionPerformed} method is invoked if the value of 2179 * the {@code "AuditoryCues.playList"} default is a {@code 2180 * non-null} {@code Object[]} containing a {@code String} entry 2181 * equal to the name of the {@code audioAction}. 2182 * 2183 * @param audioAction an Action that knows how to render the audio 2184 * associated with the system or user activity 2185 * that is occurring; a value of {@code null}, is 2186 * ignored 2187 * @throws ClassCastException if {@code audioAction} is {@code non-null} 2188 * and the value of the default {@code "AuditoryCues.playList"} 2189 * is not an {@code Object[]} 2190 * @since 1.4 2191 */ 2192 protected void playSound(Action audioAction) { 2193 if (audioAction != null) { 2194 Object[] audioStrings = (Object[]) 2195 UIManager.get("AuditoryCues.playList"); 2196 if (audioStrings != null) { 2197 // create a HashSet to help us decide to play or not 2198 HashSet<Object> audioCues = new HashSet<Object>(); 2199 for (Object audioString : audioStrings) { 2200 audioCues.add(audioString); 2201 } 2202 // get the name of the Action 2203 String actionName = (String)audioAction.getValue(Action.NAME); 2204 // if the actionName is in the audioCues HashSet, play it. 2205 if (audioCues.contains(actionName)) { 2206 audioAction.actionPerformed(new 2207 ActionEvent(this, ActionEvent.ACTION_PERFORMED, 2208 actionName)); 2209 } 2210 } 2211 } 2212 } 2213 2214 2215 /** 2216 * Sets the parent of the passed in ActionMap to be the audio action 2217 * map. 2218 */ 2219 static void installAudioActionMap(ActionMap map) { 2220 LookAndFeel laf = UIManager.getLookAndFeel(); 2221 if (laf instanceof BasicLookAndFeel) { 2222 map.setParent(((BasicLookAndFeel)laf).getAudioActionMap()); 2223 } 2224 } 2225 2226 2227 /** 2228 * Helper method to play a named sound. 2229 * 2230 * @param c JComponent to play the sound for. 2231 * @param actionKey Key for the sound. 2232 */ 2233 static void playSound(JComponent c, Object actionKey) { 2234 LookAndFeel laf = UIManager.getLookAndFeel(); 2235 if (laf instanceof BasicLookAndFeel) { 2236 ActionMap map = c.getActionMap(); 2237 if (map != null) { 2238 Action audioAction = map.get(actionKey); 2239 if (audioAction != null) { 2240 // pass off firing the Action to a utility method 2241 ((BasicLookAndFeel)laf).playSound(audioAction); 2242 } 2243 } 2244 } 2245 } 2246 2247 /** 2248 * This class contains listener that watches for all the mouse 2249 * events that can possibly invoke popup on the component 2250 */ 2251 class AWTEventHelper implements AWTEventListener,PrivilegedAction<Object> { 2252 AWTEventHelper() { 2253 super(); 2254 AccessController.doPrivileged(this); 2255 } 2256 2257 public Object run() { 2258 Toolkit tk = Toolkit.getDefaultToolkit(); 2259 if(invocator == null) { 2260 tk.addAWTEventListener(this, AWTEvent.MOUSE_EVENT_MASK); 2261 } else { 2262 tk.removeAWTEventListener(invocator); 2263 } 2264 // Return value not used. 2265 return null; 2266 } 2267 2268 public void eventDispatched(AWTEvent ev) { 2269 int eventID = ev.getID(); 2270 if((eventID & AWTEvent.MOUSE_EVENT_MASK) != 0) { 2271 MouseEvent me = (MouseEvent) ev; 2272 if(me.isPopupTrigger()) { 2273 MenuElement[] elems = MenuSelectionManager 2274 .defaultManager() 2275 .getSelectedPath(); 2276 if(elems != null && elems.length != 0) { 2277 return; 2278 // We shall not interfere with already opened menu 2279 } 2280 Object c = me.getSource(); 2281 JComponent src = null; 2282 if(c instanceof JComponent) { 2283 src = (JComponent) c; 2284 } else if(c instanceof BasicSplitPaneDivider) { 2285 // Special case - if user clicks on divider we must 2286 // invoke popup from the SplitPane 2287 src = (JComponent) 2288 ((BasicSplitPaneDivider)c).getParent(); 2289 } 2290 if(src != null) { 2291 if(src.getComponentPopupMenu() != null) { 2292 Point pt = src.getPopupLocation(me); 2293 if(pt == null) { 2294 pt = me.getPoint(); 2295 pt = SwingUtilities.convertPoint((Component)c, 2296 pt, src); 2297 } 2298 src.getComponentPopupMenu().show(src, pt.x, pt.y); 2299 me.consume(); 2300 } 2301 } 2302 } 2303 } 2304 /* Activate a JInternalFrame if necessary. */ 2305 if (eventID == MouseEvent.MOUSE_PRESSED) { 2306 Object object = ev.getSource(); 2307 if (!(object instanceof Component)) { 2308 return; 2309 } 2310 Component component = (Component)object; 2311 if (component != null) { 2312 Component parent = component; 2313 while (parent != null && !(parent instanceof Window)) { 2314 if (parent instanceof JInternalFrame) { 2315 // Activate the frame. 2316 try { ((JInternalFrame)parent).setSelected(true); } 2317 catch (PropertyVetoException e1) { } 2318 } 2319 parent = parent.getParent(); 2320 } 2321 } 2322 } 2323 } 2324 } 2325 }