Java Code Examples for javax.swing.JComponent.setDefaultLocale()

The following are Jave code examples for showing how to use setDefaultLocale() of the javax.swing.JComponent class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: jdk8u-jdk   File: Test6524757.java   View Source Code Vote up 6 votes
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);
    }
}
 
Example 2
Project: openjdk-jdk10   File: Test6524757.java   View Source Code Vote up 6 votes
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);
    }
}
 
Example 3
Project: JuggleMasterPro   File: ControlJFrame.java   View Source Code Vote up 4 votes
/**
 * Method description
 * 
 * @see
 */
final public void setLanguageJLabels(boolean bolPhideControlJFrame) {

	final Rectangle objLcontrolJFrameRectangle = this.getBounds();

	// Save the current configuration :
	final PatternsManager objLsavedJugglePatternsManager = this.getPatternsManager();
	final byte bytLsavedAnimationStatus = this.objGjuggleMasterPro.bytGanimationStatus;
	final int intLsavedObjectIndex = this.objGjuggleMasterPro.intGobjectIndex;

	// Set the special language pattern manager :
	final PatternsManager objLlanguageJugglePatternsManager = new PatternsManager(Constants.bytS_MANAGER_NEW_ABSTRACT_LANGUAGE);
	this.objGjuggleMasterPro.bytGanimationStatus = Constants.bytS_STATE_ANIMATION_PAUSED;
	this.objGjuggleMasterPro.intGobjectIndex = objLlanguageJugglePatternsManager.getPatternsFileManager().intGstartObjectIndex;
	this.setJugglePatternsManager(objLlanguageJugglePatternsManager);

	// Set dialog language :
	try {
		final Locale objLlocale = new Locale(this.getLanguageString(Language.intS_LANGUAGE_ISO_639_1_CODE));
		JComponent.setDefaultLocale(objLlocale);
	} catch (final Throwable objPthrowable) {
		Tools.err("Error while trying to apply ISO 639-1 language code");
	}

	// Place the widgets :
	this.setWidgetsPreferredSizes(false);
	this.setWidgetsControls();
	if (bolPhideControlJFrame) {
		this.setVisible(false);
		this.getJuggleMasterPro().getFrame().setVisible(false);
	}
	this.validate();
	this.pack();
	this.setWidgetsPreferredSizes(true);

	final int intLoldWidth = (int) objLcontrolJFrameRectangle.getWidth();
	final int intLnewWidth = Math.max(this.getWidth(), intLoldWidth);
	if (intLnewWidth > intLoldWidth) {
		this.setBounds(	Math.max(0, this.getX() - (intLnewWidth - intLoldWidth)),
						this.getY(),
						intLnewWidth,
						(int) objLcontrolJFrameRectangle.getHeight());
	} else {
		this.setBounds(	Math.max(0, (int) objLcontrolJFrameRectangle.getX()),
						this.getY(),
						intLoldWidth,
						(int) objLcontrolJFrameRectangle.getHeight());
	}
	if (bolPhideControlJFrame) {
		this.setVisible(true);
		this.getJuggleMasterPro().getFrame().setVisible(true);
		this.getJuggleMasterPro().getFrame().repaint();
	}

	// Restore the previous configuration :
	this.setJugglePatternsManager(objLsavedJugglePatternsManager);
	this.objGjuggleMasterPro.intGobjectIndex = intLsavedObjectIndex;
	this.objGjuggleMasterPro.bytGanimationStatus = bytLsavedAnimationStatus;
	this.setWidgetsControls();
	this.setJButtonsEnabled(true);
	this.repaint();

	// Set the menus :
	this.setMenusJLabels();
	this.setMenusEnabled();
	this.objGjuggleMasterPro.objGdataJFrame.setHeaders();
	this.objGjuggleMasterPro.objGdataJFrame.setButtonsJLabels();
}