setting look and feel automatically
This commit is contained in:
parent
d8bdad548d
commit
64f0b7d0c8
|
@ -40,11 +40,42 @@ public final class Main {
|
|||
|
||||
Locales.autodetectDefaultLocale();
|
||||
|
||||
setPlatformDependingTheme();
|
||||
|
||||
// create main instance and show the login screen
|
||||
instance();
|
||||
getInstance().showLoginScreen();
|
||||
}
|
||||
|
||||
private static void setPlatformDependingTheme() {
|
||||
// default look and feel
|
||||
var laf = UIManager.getCrossPlatformLookAndFeelClassName();
|
||||
|
||||
// runtime os
|
||||
String os = System.getProperty("os.name").toLowerCase();
|
||||
LOGGER.fine("Detected operating system: " + os);
|
||||
|
||||
// set look and feel class name depending on the platform we run on
|
||||
if (os.contains("win") || os.contains("mac")) {
|
||||
LOGGER.info("Detected Windows or MacOS based operating system, using system look and feel");
|
||||
laf = UIManager.getSystemLookAndFeelClassName();
|
||||
} else if (os.contains("nix") || os.contains("nux") || os.contains("aix") || os.contains("sunos")) {
|
||||
LOGGER.info("Detected Unix/Linux based operating system, using GTK look and feel");
|
||||
laf = "com.sun.java.swing.plaf.gtk.GTKLookAndFeel";
|
||||
} else {
|
||||
LOGGER.warning("Unable to detect operating system: " + os);
|
||||
}
|
||||
|
||||
try {
|
||||
LOGGER.info("Setting look and feel to class: " + laf);
|
||||
UIManager.setLookAndFeel(laf);
|
||||
} catch (ClassNotFoundException | UnsupportedLookAndFeelException e) {
|
||||
LOGGER.severe("Look and feel class not found: " + e.getMessage());
|
||||
} catch (InstantiationException | IllegalAccessException e) {
|
||||
LOGGER.warning("Could not set look and feel: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the main singleton instance of this program
|
||||
* @return the singleton instance of this class
|
||||
|
|
|
@ -8,6 +8,7 @@ import javax.swing.*;
|
|||
import javax.swing.filechooser.FileNameExtensionFilter;
|
||||
|
||||
import static javax.swing.JFileChooser.APPROVE_OPTION;
|
||||
import static me.teridax.jcash.lang.Translator.translate;
|
||||
|
||||
/**
|
||||
* Utility class for loading a BMS configuration from a csv file.
|
||||
|
@ -17,7 +18,7 @@ public class Loader {
|
|||
/**
|
||||
* Filter that only allows for files with *.csv extension
|
||||
*/
|
||||
private static final FileNameExtensionFilter FILE_FILTER = new FileNameExtensionFilter("Comma separated value spreadsheet", "csv", "CSV");
|
||||
private static final FileNameExtensionFilter FILE_FILTER = new FileNameExtensionFilter(translate("Comma separated value spreadsheet"), "csv", "CSV");
|
||||
|
||||
private Loader() {}
|
||||
|
||||
|
@ -35,7 +36,7 @@ public class Loader {
|
|||
fileChooser.setDialogType(JFileChooser.OPEN_DIALOG);
|
||||
fileChooser.setAcceptAllFileFilterUsed(false);
|
||||
|
||||
if (fileChooser.showDialog(null, Translator.translate("Load database")) == APPROVE_OPTION) {
|
||||
if (fileChooser.showDialog(null, translate("Load database")) == APPROVE_OPTION) {
|
||||
// parse file content
|
||||
try {
|
||||
return BankingManagementSystem.loadFromCsv(fileChooser.getSelectedFile().toPath());
|
||||
|
|
|
@ -46,3 +46,4 @@ Address,Adresse,Dirección,Adresse,地址
|
|||
Account,Konto,Cuenta,Compte,账户
|
||||
Closing JCash,JCash wird geschlossen,JCash está cerrado,JCash est fermé,JCash 已关闭
|
||||
you're logged out,Du bist abgemeldet,Ha cerrado la sesión,Tu es déconnecté,您已注销
|
||||
Comma separated value spreadsheet,Tabelle mit kommagetrennten Werten,Planilla de valores separados por comas,Feuille de calcul à valeurs séparées par des virgules,逗号分隔值电子表格
|
|
Loading…
Reference in New Issue