下面列出了javax.swing.JComponent#setDefaultLocale ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
public static void 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);
}
}
public static void 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);
}
}
public static void 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);
}
}
public static void 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);
}
}
public static void 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);
}
}
public static void 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);
}
}
public static void 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);
}
}
public static void 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);
}
}
public static void 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);
}
}
public static void 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);
}
}
public static void 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);
}
}
public static void 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);
}
}
public static void 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);
}
}
public static void setLocale(Locale localeUI){
Locale.setDefault( localeUI );
JComponent.setDefaultLocale( localeUI );
RESOURCE_BUNDLE = ResourceBundle.getBundle(BUNDLE_NAME);
}