diff --git a/src/me/teridax/jcash/Main.java b/src/me/teridax/jcash/Main.java index 5403e1a..a336bdc 100644 --- a/src/me/teridax/jcash/Main.java +++ b/src/me/teridax/jcash/Main.java @@ -1,11 +1,15 @@ package me.teridax.jcash; +import me.teridax.jcash.gui.IconProvider; import me.teridax.jcash.gui.Loader; import me.teridax.jcash.gui.account.AccountController; import me.teridax.jcash.gui.login.LoginController; import me.teridax.jcash.lang.Locales; +import javax.imageio.ImageIO; import javax.swing.*; +import java.awt.*; +import java.io.IOException; import java.util.Objects; import java.util.logging.*; @@ -33,6 +37,7 @@ public final class Main { this.window.setTitle(translate("Cashmachine")); this.window.setLocationByPlatform(true); this.window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + this.window.setIconImage(IconProvider.getWindowIcon()); } public static void main(String[] args) { @@ -152,4 +157,8 @@ public final class Main { window.setContentPane(new JLabel(translate("you're logged out"))); window.setVisible(false); } + + public JFrame getWindow() { + return this.window; + } } \ No newline at end of file diff --git a/src/me/teridax/jcash/gui/IconProvider.java b/src/me/teridax/jcash/gui/IconProvider.java new file mode 100644 index 0000000..ea0e92b --- /dev/null +++ b/src/me/teridax/jcash/gui/IconProvider.java @@ -0,0 +1,30 @@ +package me.teridax.jcash.gui; + +import me.teridax.jcash.Main; + +import javax.imageio.ImageIO; +import java.awt.*; +import java.awt.image.BufferedImage; +import java.util.Objects; + +import static me.teridax.jcash.Logging.LOGGER; + +public class IconProvider { + + private static final Image DEFAULT_IMAGE = new BufferedImage(256, 256, BufferedImage.TYPE_INT_RGB); + + public static Image getWindowIcon() { + return loadIcon("res/register.png"); + } + + private static Image loadIcon(String path) { + try { + var is = Objects.requireNonNull(IconProvider.class.getResourceAsStream(path)); + return ImageIO.read(is); + } catch (Exception e) { + LOGGER.severe("Unable to load icon " + path + " because: " + e.getMessage()); + } + + return DEFAULT_IMAGE; + } +} diff --git a/src/me/teridax/jcash/gui/Loader.java b/src/me/teridax/jcash/gui/Loader.java index 79321da..7c54bd8 100644 --- a/src/me/teridax/jcash/gui/Loader.java +++ b/src/me/teridax/jcash/gui/Loader.java @@ -1,6 +1,7 @@ package me.teridax.jcash.gui; import me.teridax.jcash.Logging; +import me.teridax.jcash.Main; import me.teridax.jcash.banking.management.BankingManagementSystem; import javax.swing.*; @@ -35,7 +36,7 @@ public class Loader { fileChooser.setDialogType(JFileChooser.OPEN_DIALOG); fileChooser.setAcceptAllFileFilterUsed(false); - if (fileChooser.showDialog(null, translate("Load database")) == APPROVE_OPTION) { + if (fileChooser.showDialog(Main.getInstance().getWindow(), translate("Load database")) == APPROVE_OPTION) { // parse file content try { return BankingManagementSystem.loadFromCsv(fileChooser.getSelectedFile().toPath()); diff --git a/src/me/teridax/jcash/gui/account/AccountView.java b/src/me/teridax/jcash/gui/account/AccountView.java index 6381130..f663098 100644 --- a/src/me/teridax/jcash/gui/account/AccountView.java +++ b/src/me/teridax/jcash/gui/account/AccountView.java @@ -51,7 +51,7 @@ public class AccountView extends JPanel { this.balance.setText(StringDecoder.LOCAL_NUMBER_FORMAT.format(account.getBalance()) + " €"); - this.type.setText(account.getClass().getSimpleName()); + this.type.setText(translate(account.getClass().getSimpleName())); if (account instanceof CurrentAccount) {; this.typeSpecialLabel.setText(translate("Overdraft")); this.typeSpecialProperty.setText( StringDecoder.LOCAL_NUMBER_FORMAT.format(((CurrentAccount) account).getOverdraft()) + " €"); diff --git a/src/me/teridax/jcash/gui/res/image-sources.md b/src/me/teridax/jcash/gui/res/image-sources.md new file mode 100644 index 0000000..62148ed --- /dev/null +++ b/src/me/teridax/jcash/gui/res/image-sources.md @@ -0,0 +1,2 @@ +https://pixabay.com/vectors/register-cash-register-modern-23666/ +![register](https://cdn.pixabay.com/photo/2012/04/01/17/34/register-23666_960_720.png) \ No newline at end of file diff --git a/src/me/teridax/jcash/gui/res/register.png b/src/me/teridax/jcash/gui/res/register.png new file mode 100644 index 0000000..e2b7258 Binary files /dev/null and b/src/me/teridax/jcash/gui/res/register.png differ diff --git a/src/me/teridax/jcash/gui/takeoff/TakeoffDialog.java b/src/me/teridax/jcash/gui/takeoff/TakeoffDialog.java index bfff13b..18f338f 100644 --- a/src/me/teridax/jcash/gui/takeoff/TakeoffDialog.java +++ b/src/me/teridax/jcash/gui/takeoff/TakeoffDialog.java @@ -1,6 +1,7 @@ package me.teridax.jcash.gui.takeoff; import me.teridax.jcash.Logging; +import me.teridax.jcash.Main; import me.teridax.jcash.banking.accounts.Account; import static javax.swing.JOptionPane.ERROR_MESSAGE; @@ -31,7 +32,7 @@ public class TakeoffDialog { view.dispose(); } catch (IllegalArgumentException ex) { Logging.LOGGER.severe("Could not take off money: " + ex.getMessage()); - showMessageDialog(null, "Reason: " + ex.getMessage(), translate("Could not take off money"), ERROR_MESSAGE); + showMessageDialog(Main.getInstance().getWindow(), "Reason: " + ex.getMessage(), translate("Could not take off money"), ERROR_MESSAGE); } } } diff --git a/src/me/teridax/jcash/gui/transfer/TransferDialog.java b/src/me/teridax/jcash/gui/transfer/TransferDialog.java index 751fd29..66333ce 100644 --- a/src/me/teridax/jcash/gui/transfer/TransferDialog.java +++ b/src/me/teridax/jcash/gui/transfer/TransferDialog.java @@ -1,6 +1,7 @@ package me.teridax.jcash.gui.transfer; import me.teridax.jcash.Logging; +import me.teridax.jcash.Main; import me.teridax.jcash.banking.accounts.Account; import me.teridax.jcash.banking.management.BankingManagementSystem; @@ -39,7 +40,7 @@ public class TransferDialog { this.transferView.dispose(); } catch (IllegalArgumentException ex) { Logging.LOGGER.severe("Could not transfer: " + ex.getMessage()); - showMessageDialog(null, translate("Invalid account"), translate("Could not transfer"), ERROR_MESSAGE); + showMessageDialog(Main.getInstance().getWindow(), translate("Invalid account"), translate("Could not transfer"), ERROR_MESSAGE); } } } diff --git a/src/me/teridax/jcash/lang/languages.csv b/src/me/teridax/jcash/lang/languages.csv index 46e76d2..3da96e4 100644 --- a/src/me/teridax/jcash/lang/languages.csv +++ b/src/me/teridax/jcash/lang/languages.csv @@ -14,8 +14,8 @@ PLZ,PLZ,PLZ,NPA,邮政编码 City,Ort,Ubicación,Ville,城市 Password,Passwort,contraseña,Mot de passe,密码 Login,Anmelden,Inicio de sesión,S'inscrire,登录 -Current account,Girokonto,Cuenta corriente,Compte courant,活期账户 -Savings account,Sparkonto,Cuenta de ahorro,Compte d'épargne,储蓄账户 +CurrentAccount,Girokonto,Cuenta corriente,Compte courant,活期账户 +SavingsAccount,Sparkonto,Cuenta de ahorro,Compte d'épargne,储蓄账户 Address,Adresse,Dirección,Adresse,地址 Logout,Abmelden,desconectarse,Se désinscrire,退出登录 Transfer,Überweisen,transferencia,Virement bancaire,转账