diff --git a/src/main/java/fucoin/gui/WalletGuiControlImpl.java b/src/main/java/fucoin/gui/WalletGuiControlImpl.java index 49c69b9408d320ac404f5194b4e856c50c80c480..deed026356d5efa0f33634db0e9ed8e840f04990 100644 --- a/src/main/java/fucoin/gui/WalletGuiControlImpl.java +++ b/src/main/java/fucoin/gui/WalletGuiControlImpl.java @@ -7,6 +7,7 @@ import javax.swing.*; import java.awt.*; import java.awt.event.*; import java.util.Enumeration; +import java.text.NumberFormat; public class WalletGuiControlImpl implements WalletGuiControl { @@ -22,7 +23,7 @@ public class WalletGuiControlImpl implements WalletGuiControl { private JLabel lblSendTo = new JLabel("Send to:"); private JComboBox<String> txtSendTo = new JComboBox<>(); private JLabel lblSendAmount = new JLabel("Amount:"); - private JTextField txtSendAmount = new JTextField(""); + private JTextField txtSendAmount = new JFormattedTextField(NumberFormat.getNumberInstance()); private JButton btnSend = new JButton("Send"); private JButton btnSearch = new JButton("Search"); private JButton btnStore = new JButton("Store"); @@ -128,8 +129,13 @@ public class WalletGuiControlImpl implements WalletGuiControl { window.setVisible(true); btnSend.addActionListener(e -> { - wallet.send(txtSendTo.getSelectedItem().toString(), - Integer.parseInt(txtSendAmount.getText())); + String sendAmount = txtSendAmount.getText(); + if(sendAmount.trim().equalsIgnoreCase("")) { + JOptionPane.showMessageDialog(new JFrame("Warning"), "You need to type a number of coins to send."); + } else { + wallet.send(txtSendTo.getSelectedItem().toString(), + Integer.parseInt(sendAmount)); + } }); btnStore.addActionListener(e -> {