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