Improved aboutDialog + locale in SibaGUI
This commit is contained in:
parent
505dcaf1f5
commit
36e8196940
@ -32,7 +32,6 @@ import org.slf4j.LoggerFactory;
|
||||
* This class Siba stands for Simple Backup. This is the main class.
|
||||
*
|
||||
*
|
||||
* @param args
|
||||
*/
|
||||
public class Siba
|
||||
{
|
||||
|
@ -182,6 +182,9 @@ public class SibaCLI
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public static void sibaCLIException()
|
||||
{
|
||||
// Set default CLI catch.
|
||||
|
@ -29,7 +29,6 @@ import java.awt.Toolkit;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.util.Locale;
|
||||
|
||||
import javax.swing.Box;
|
||||
@ -120,8 +119,7 @@ public class AboutDialog extends JDialog
|
||||
{
|
||||
resource = "/org/dclermonte/siba/gui/about_en.html";
|
||||
}
|
||||
URL url = AboutDialog.class.getResource(resource);
|
||||
txtpnSimpleBackupDveloppeur.setText(SibaUtils.readResource(resource, url));
|
||||
txtpnSimpleBackupDveloppeur.setText(SibaUtils.readResource(resource));
|
||||
panel.add(txtpnSimpleBackupDveloppeur);
|
||||
{
|
||||
JLabel lblNewLabel = new JLabel("");
|
||||
|
@ -70,7 +70,7 @@ public class SibaGUI
|
||||
/**
|
||||
* Launch the application.
|
||||
*/
|
||||
private Locale locale;
|
||||
|
||||
private BackupPanel backupPanel;
|
||||
private CheckPanel checkPanel;
|
||||
|
||||
@ -85,6 +85,7 @@ public class SibaGUI
|
||||
public SibaGUI() throws ClassNotFoundException, InstantiationException, IllegalAccessException,
|
||||
UnsupportedLookAndFeelException, SibaException
|
||||
{
|
||||
final Locale locale;
|
||||
// Set default GUI catch.
|
||||
Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler()
|
||||
{
|
||||
@ -143,9 +144,9 @@ public class SibaGUI
|
||||
logger.debug("Activated lookAndFeel: {} ", UIManager.getLookAndFeel().getName());
|
||||
|
||||
// Set default locale.
|
||||
this.locale = Locale.getDefault();
|
||||
updateLanguage(this.locale);
|
||||
logger.debug(this.locale.getDisplayLanguage());
|
||||
locale = Locale.getDefault();
|
||||
updateLanguage(locale);
|
||||
logger.debug(locale.getDisplayLanguage());
|
||||
initialize();
|
||||
|
||||
}
|
||||
@ -287,24 +288,6 @@ public class SibaGUI
|
||||
mnNewMenu.add(mntmMenuItemAbout);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method set the local language.
|
||||
*/
|
||||
public final void updateLanguage(final Locale source)
|
||||
{
|
||||
// Change JVM default locale.
|
||||
java.util.Locale.setDefault(source);
|
||||
|
||||
// Change LookAndFeel default locale.
|
||||
javax.swing.UIManager.getDefaults().setDefaultLocale(source);
|
||||
|
||||
// Change new component default locale.
|
||||
javax.swing.JComponent.setDefaultLocale(source);
|
||||
|
||||
//
|
||||
ResourceBundle.clearCache();
|
||||
}
|
||||
|
||||
/**
|
||||
* This method launch the GUI.
|
||||
*/
|
||||
@ -335,4 +318,22 @@ public class SibaGUI
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* This method set the local language.
|
||||
*/
|
||||
public static void updateLanguage(final Locale source)
|
||||
{
|
||||
// Change JVM default locale.
|
||||
java.util.Locale.setDefault(source);
|
||||
|
||||
// Change LookAndFeel default locale.
|
||||
javax.swing.UIManager.getDefaults().setDefaultLocale(source);
|
||||
|
||||
// Change new component default locale.
|
||||
javax.swing.JComponent.setDefaultLocale(source);
|
||||
|
||||
//
|
||||
ResourceBundle.clearCache();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -228,11 +228,13 @@ public class SibaUtils
|
||||
* @return
|
||||
* @throws IOException
|
||||
*/
|
||||
public static String readResource(final String resource, final URL url) throws IOException
|
||||
public static String readResource(final String resource) throws IOException
|
||||
{
|
||||
String result;
|
||||
|
||||
result = IOUtils.toString(url, (String) null);
|
||||
final String DEFAULT_CHARSET = "UTF-8";
|
||||
URL url = SibaUtils.class.getResource(resource);
|
||||
result = IOUtils.toString(url, DEFAULT_CHARSET);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user