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