Skip to content
Snippets Groups Projects
Commit 76d1ee85 authored by Spark Fountain's avatar Spark Fountain
Browse files

added warning if send amount is not set

parent 1e3a38f7
No related branches found
No related tags found
No related merge requests found
...@@ -7,6 +7,7 @@ import javax.swing.*; ...@@ -7,6 +7,7 @@ import javax.swing.*;
import java.awt.*; import java.awt.*;
import java.awt.event.*; import java.awt.event.*;
import java.util.Enumeration; import java.util.Enumeration;
import java.text.NumberFormat;
public class WalletGuiControlImpl implements WalletGuiControl { public class WalletGuiControlImpl implements WalletGuiControl {
...@@ -22,7 +23,7 @@ public class WalletGuiControlImpl implements WalletGuiControl { ...@@ -22,7 +23,7 @@ public class WalletGuiControlImpl implements WalletGuiControl {
private JLabel lblSendTo = new JLabel("Send to:"); private JLabel lblSendTo = new JLabel("Send to:");
private JComboBox<String> txtSendTo = new JComboBox<>(); private JComboBox<String> txtSendTo = new JComboBox<>();
private JLabel lblSendAmount = new JLabel("Amount:"); 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 btnSend = new JButton("Send");
private JButton btnSearch = new JButton("Search"); private JButton btnSearch = new JButton("Search");
private JButton btnStore = new JButton("Store"); private JButton btnStore = new JButton("Store");
...@@ -128,8 +129,13 @@ public class WalletGuiControlImpl implements WalletGuiControl { ...@@ -128,8 +129,13 @@ public class WalletGuiControlImpl implements WalletGuiControl {
window.setVisible(true); window.setVisible(true);
btnSend.addActionListener(e -> { btnSend.addActionListener(e -> {
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(), wallet.send(txtSendTo.getSelectedItem().toString(),
Integer.parseInt(txtSendAmount.getText())); Integer.parseInt(sendAmount));
}
}); });
btnStore.addActionListener(e -> { btnStore.addActionListener(e -> {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment