/* * Copyright (c) 2007, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions.
*/
publicclass Test6524757 { privatestaticfinal String[] KEYS = { "ColorChooser.okText", // NON-NLS: string key from JColorChooser "ColorChooser.cancelText", // NON-NLS: string key from JColorChooser "ColorChooser.resetText", // NON-NLS: string key from JColorChooser "ColorChooser.resetMnemonic", // NON-NLS: int key from JColorChooser
//NotAvail: "ColorChooser.sampleText", // NON-NLS: string key from DefaultPreviewPanel
"ColorChooser.swatchesNameText", // NON-NLS: string key from DefaultSwatchChooserPanel "ColorChooser.swatchesMnemonic", // NON-NLS: string key from DefaultSwatchChooserPanel:int "ColorChooser.swatchesSwatchSize", // NON-NLS: dimension key from DefaultSwatchChooserPanel "ColorChooser.swatchesRecentText", // NON-NLS: string key from DefaultSwatchChooserPanel "ColorChooser.swatchesRecentSwatchSize", // NON-NLS: dimension key from DefaultSwatchChooserPanel //NotAvail: "ColorChooser.swatchesDefaultRecentColor", // NON-NLS: color key from DefaultSwatchChooserPanel
"ColorChooser.hsvNameText", // NON-NLS: string key from HSV ColorChooserPanel "ColorChooser.hsvMnemonic", // NON-NLS: int key from HSV ColorChooserPanel "ColorChooser.hsvHueText", // NON-NLS: string key from HSV ColorChooserPanel "ColorChooser.hsvSaturationText", // NON-NLS: string key from HSV ColorChooserPanel "ColorChooser.hsvValueText", // NON-NLS: string key from HSV ColorChooserPanel "ColorChooser.hsvTransparencyText", // NON-NLS: string key from HSV ColorChooserPanel
"ColorChooser.hslNameText", // NON-NLS: string key from HSV ColorChooserPanel "ColorChooser.hslMnemonic", // NON-NLS: int key from HSV ColorChooserPanel "ColorChooser.hslHueText", // NON-NLS: string key from HSV ColorChooserPanel "ColorChooser.hslSaturationText", // NON-NLS: string key from HSV ColorChooserPanel "ColorChooser.hslLightnessText", // NON-NLS: string key from HSV ColorChooserPanel "ColorChooser.hslTransparencyText", // NON-NLS: string key from HSV ColorChooserPanel
"ColorChooser.rgbNameText", // NON-NLS: string key from HSV ColorChooserPanel "ColorChooser.rgbMnemonic", // NON-NLS: int key from HSV ColorChooserPanel "ColorChooser.rgbRedText", // NON-NLS: string key from HSV ColorChooserPanel "ColorChooser.rgbGreenText", // NON-NLS: string key from HSV ColorChooserPanel "ColorChooser.rgbBlueText", // NON-NLS: string key from HSV ColorChooserPanel "ColorChooser.rgbAlphaText", // NON-NLS: string key from HSV ColorChooserPanel "ColorChooser.rgbHexCodeText", // NON-NLS: string key from HSV ColorChooserPanel "ColorChooser.rgbHexCodeMnemonic", // NON-NLS: int key from HSV ColorChooserPanel
"ColorChooser.cmykNameText", // NON-NLS: string key from HSV ColorChooserPanel "ColorChooser.cmykMnemonic", // NON-NLS: int key from HSV ColorChooserPanel "ColorChooser.cmykCyanText", // NON-NLS: string key from HSV ColorChooserPanel "ColorChooser.cmykMagentaText", // NON-NLS: string key from HSV ColorChooserPanel "ColorChooser.cmykYellowText", // NON-NLS: string key from HSV ColorChooserPanel "ColorChooser.cmykBlackText", // NON-NLS: string key from HSV ColorChooserPanel "ColorChooser.cmykAlphaText", // NON-NLS: string key from HSV ColorChooserPanel
}; privatestaticfinal Object[] KOREAN = convert(Locale.KOREAN, KEYS); privatestaticfinal Object[] FRENCH = convert(Locale.FRENCH, KEYS);
publicstaticvoid main(String[] args) {
Locale reservedLocale = Locale.getDefault(); try { // it affects Swing because it is not initialized
Locale.setDefault(Locale.KOREAN);
validate(KOREAN, create());
// it does not affect Swing because it is initialized
Locale.setDefault(Locale.CANADA);
validate(KOREAN, create());
// it definitely should affect Swing
JComponent.setDefaultLocale(Locale.FRENCH);
validate(FRENCH, create());
} finally { // restore the reserved locale
Locale.setDefault(reservedLocale);
}
}
privatestaticvoid validate(Object[] expected, Object[] actual) { int count = expected.length; if (count != actual.length) { thrownew Error("different size: " + count + " <> " + actual.length);
} for (int i = 0; i < count; i++) { if (!expected[i].equals(actual[i])) { thrownew Error("unexpected value for key: " + KEYS[i]);
}
}
}
privatestatic Object[] convert(Locale locale, String[] keys) { int count = keys.length;
Object[] array = new Object[count]; for (int i = 0; i < count; i++) {
array[i] = convert(locale, keys[i]);
} return array;
}
privatestatic Object convert(Locale locale, String key) { if (key.endsWith("Text")) { // NON-NLS: suffix for text message return UIManager.getString(key, locale);
} if (key.endsWith("Size")) { // NON-NLS: suffix for dimension return UIManager.getDimension(key, locale);
} if (key.endsWith("Color")) { // NON-NLS: suffix for color return UIManager.getColor(key, locale);
} int value = SwingUtilities2.getUIDefaultsInt(key, locale, -1); return Integer.valueOf(value);
}
// close dialog
dialog.setVisible(false);
dialog.dispose();
// close frame
frame.setVisible(false);
frame.dispose();
return list.toArray();
}
privatestaticvoid addSize(List<Object> list, Component component, int x, int y, int w, int h) {
Dimension size = component.getPreferredSize(); int width = (size.width + 1) / w - x; int height = (size.height + 1) / h - y;
list.add(new Dimension(width, height));
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.