customized login button

This commit is contained in:
Sven Vogel 2023-07-22 15:35:03 +02:00
parent d0557a2a6d
commit c88212b7e1
8 changed files with 46 additions and 7 deletions

View File

@ -9,6 +9,7 @@ import me.teridax.jcash.lang.Locales;
import javax.swing.*; import javax.swing.*;
import java.awt.*; import java.awt.*;
import java.io.IOException;
import java.util.Objects; import java.util.Objects;
import java.util.logging.Level; import java.util.logging.Level;
@ -78,15 +79,27 @@ public final class Main {
public static void main(String[] args) { public static void main(String[] args) {
initializeSystemLogger(Level.FINE); initializeSystemLogger(Level.FINE);
Locales.autodetectDefaultLocale();
setPlatformDependingTheme(); setPlatformDependingTheme();
loadExtraFont();
Locales.autodetectDefaultLocale();
// create main instance and show the login screen // create main instance and show the login screen
instance(); instance();
getInstance().loadDatabase(); getInstance().loadDatabase();
} }
private static void loadExtraFont() {
try {
var font = Font.createFont(Font.TRUETYPE_FONT, IconProvider.class.getResourceAsStream("res/Circus.ttf"));
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
ge.registerFont(font);
} catch (IOException | FontFormatException e) {
e.printStackTrace();
}
}
/** /**
* Set the look and feel via the ui manager. * Set the look and feel via the ui manager.
* This function will select a look and feel so that the application will * This function will select a look and feel so that the application will

View File

@ -25,4 +25,8 @@ public class IconProvider {
return DEFAULT_IMAGE; return DEFAULT_IMAGE;
} }
public static Image getSetupIcon() {
return loadIcon("res/login.jpg");
}
} }

View File

@ -1,6 +1,7 @@
package me.teridax.jcash.gui.account; package me.teridax.jcash.gui.account;
import me.teridax.jcash.Logging; import me.teridax.jcash.Logging;
import me.teridax.jcash.banking.accounts.Account;
import me.teridax.jcash.banking.accounts.CurrentAccount; import me.teridax.jcash.banking.accounts.CurrentAccount;
import me.teridax.jcash.banking.accounts.SavingsAccount; import me.teridax.jcash.banking.accounts.SavingsAccount;
import me.teridax.jcash.banking.management.Profile; import me.teridax.jcash.banking.management.Profile;
@ -8,6 +9,8 @@ import me.teridax.jcash.decode.StringDecoder;
import javax.swing.*; import javax.swing.*;
import java.awt.*; import java.awt.*;
import java.util.Arrays;
import java.util.Comparator;
import static javax.swing.SwingConstants.RIGHT; import static javax.swing.SwingConstants.RIGHT;
import static me.teridax.jcash.gui.Utils.addGridBagRow; import static me.teridax.jcash.gui.Utils.addGridBagRow;
@ -42,9 +45,9 @@ public class AccountView extends JPanel {
this.accountSelection.removeAllItems(); this.accountSelection.removeAllItems();
for (var otherAccount : profile.getAccounts()) { var accounts = profile.getAccounts();
this.accountSelection.addItem(otherAccount.getDescription()); Arrays.stream(accounts).sorted(Comparator.comparingInt(Account::getIban)).forEach(a -> this.accountSelection.addItem(a.getDescription()));
}
this.accountSelection.setSelectedItem(profile.getPrimaryAccount().getDescription()); this.accountSelection.setSelectedItem(profile.getPrimaryAccount().getDescription());
} }

View File

@ -1,8 +1,11 @@
package me.teridax.jcash.gui.login; package me.teridax.jcash.gui.login;
import me.teridax.jcash.gui.IconProvider;
import javax.swing.*; import javax.swing.*;
import javax.swing.text.*; import javax.swing.text.*;
import java.awt.*; import java.awt.*;
import java.io.IOException;
import java.text.NumberFormat; import java.text.NumberFormat;
import static java.awt.BorderLayout.NORTH; import static java.awt.BorderLayout.NORTH;
@ -60,6 +63,10 @@ public class LoginView extends JPanel {
this.pin = new JPasswordField(); this.pin = new JPasswordField();
this.login = new JButton(translate("Login")); this.login = new JButton(translate("Login"));
this.login.setFont(new Font("Circus", Font.PLAIN, 72));
this.login.setBackground(Color.RED);
this.login.setForeground(Color.CYAN);
restrictPasswordToDigits(); restrictPasswordToDigits();
} }

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 294 KiB

View File

@ -2,6 +2,7 @@ package me.teridax.jcash.gui.takeoff;
import me.teridax.jcash.Logging; import me.teridax.jcash.Logging;
import me.teridax.jcash.banking.accounts.Account; import me.teridax.jcash.banking.accounts.Account;
import me.teridax.jcash.banking.accounts.CurrentAccount;
import me.teridax.jcash.gui.InvalidInputException; import me.teridax.jcash.gui.InvalidInputException;
import me.teridax.jcash.gui.Utils; import me.teridax.jcash.gui.Utils;
@ -18,8 +19,13 @@ public class TakeoffController {
public TakeoffController(Account account) { public TakeoffController(Account account) {
this.account = account; this.account = account;
var overdraft = 0.0;
if (account instanceof CurrentAccount) {
overdraft += ((CurrentAccount) account).getOverdraft();
}
this.data = new TakeoffData(account.getBalance()); this.data = new TakeoffData(account.getBalance());
this.view = new TakeoffView(this.data.getMaxValue()); this.view = new TakeoffView(this.data.getMaxValue() + overdraft);
this.view.getTakeoff().addActionListener(e -> takeOff()); this.view.getTakeoff().addActionListener(e -> takeOff());
this.view.getCancel().addActionListener(e -> view.dispose()); this.view.getCancel().addActionListener(e -> view.dispose());

View File

@ -3,6 +3,7 @@ package me.teridax.jcash.gui.transfer;
import me.teridax.jcash.Logging; import me.teridax.jcash.Logging;
import me.teridax.jcash.Main; import me.teridax.jcash.Main;
import me.teridax.jcash.banking.accounts.Account; import me.teridax.jcash.banking.accounts.Account;
import me.teridax.jcash.banking.accounts.CurrentAccount;
import me.teridax.jcash.banking.management.BankingManagementSystem; import me.teridax.jcash.banking.management.BankingManagementSystem;
import me.teridax.jcash.gui.InvalidInputException; import me.teridax.jcash.gui.InvalidInputException;
import me.teridax.jcash.gui.Utils; import me.teridax.jcash.gui.Utils;
@ -23,7 +24,12 @@ public class TransferController {
public TransferController(Account account, BankingManagementSystem bms) { public TransferController(Account account, BankingManagementSystem bms) {
this.account = account; this.account = account;
this.view = new TransferView(account.getBalance()); var overdraft = 0.0;
if (account instanceof CurrentAccount) {
overdraft += ((CurrentAccount) account).getOverdraft();
}
this.view = new TransferView(account.getBalance() + overdraft);
this.transferData = new TransferData(bms); this.transferData = new TransferData(bms);
this.view.getTransfer().addActionListener(e -> transfer()); this.view.getTransfer().addActionListener(e -> transfer());
this.view.getCancel().addActionListener(e -> view.dispose());this.view.getValue().getDocument().addDocumentListener(new DocumentListener() { this.view.getCancel().addActionListener(e -> view.dispose());this.view.getValue().getDocument().addDocumentListener(new DocumentListener() {