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.
|
* This class Siba stands for Simple Backup. This is the main class.
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* @param args
|
|
||||||
*/
|
*/
|
||||||
public class Siba
|
public class Siba
|
||||||
{
|
{
|
||||||
|
@ -182,6 +182,9 @@ public class SibaCLI
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
public static void sibaCLIException()
|
public static void sibaCLIException()
|
||||||
{
|
{
|
||||||
// Set default CLI catch.
|
// Set default CLI catch.
|
||||||
|
@ -29,7 +29,6 @@ import java.awt.Toolkit;
|
|||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
import java.awt.event.ActionListener;
|
import java.awt.event.ActionListener;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.URL;
|
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
import javax.swing.Box;
|
import javax.swing.Box;
|
||||||
@ -120,8 +119,7 @@ public class AboutDialog extends JDialog
|
|||||||
{
|
{
|
||||||
resource = "/org/dclermonte/siba/gui/about_en.html";
|
resource = "/org/dclermonte/siba/gui/about_en.html";
|
||||||
}
|
}
|
||||||
URL url = AboutDialog.class.getResource(resource);
|
txtpnSimpleBackupDveloppeur.setText(SibaUtils.readResource(resource));
|
||||||
txtpnSimpleBackupDveloppeur.setText(SibaUtils.readResource(resource, url));
|
|
||||||
panel.add(txtpnSimpleBackupDveloppeur);
|
panel.add(txtpnSimpleBackupDveloppeur);
|
||||||
{
|
{
|
||||||
JLabel lblNewLabel = new JLabel("");
|
JLabel lblNewLabel = new JLabel("");
|
||||||
|
@ -70,7 +70,7 @@ public class SibaGUI
|
|||||||
/**
|
/**
|
||||||
* Launch the application.
|
* Launch the application.
|
||||||
*/
|
*/
|
||||||
private Locale locale;
|
|
||||||
private BackupPanel backupPanel;
|
private BackupPanel backupPanel;
|
||||||
private CheckPanel checkPanel;
|
private CheckPanel checkPanel;
|
||||||
|
|
||||||
@ -85,6 +85,7 @@ public class SibaGUI
|
|||||||
public SibaGUI() throws ClassNotFoundException, InstantiationException, IllegalAccessException,
|
public SibaGUI() throws ClassNotFoundException, InstantiationException, IllegalAccessException,
|
||||||
UnsupportedLookAndFeelException, SibaException
|
UnsupportedLookAndFeelException, SibaException
|
||||||
{
|
{
|
||||||
|
final Locale locale;
|
||||||
// Set default GUI catch.
|
// Set default GUI catch.
|
||||||
Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler()
|
Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler()
|
||||||
{
|
{
|
||||||
@ -143,9 +144,9 @@ public class SibaGUI
|
|||||||
logger.debug("Activated lookAndFeel: {} ", UIManager.getLookAndFeel().getName());
|
logger.debug("Activated lookAndFeel: {} ", UIManager.getLookAndFeel().getName());
|
||||||
|
|
||||||
// Set default locale.
|
// Set default locale.
|
||||||
this.locale = Locale.getDefault();
|
locale = Locale.getDefault();
|
||||||
updateLanguage(this.locale);
|
updateLanguage(locale);
|
||||||
logger.debug(this.locale.getDisplayLanguage());
|
logger.debug(locale.getDisplayLanguage());
|
||||||
initialize();
|
initialize();
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -287,24 +288,6 @@ public class SibaGUI
|
|||||||
mnNewMenu.add(mntmMenuItemAbout);
|
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.
|
* 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
|
* @return
|
||||||
* @throws IOException
|
* @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;
|
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;
|
return result;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user