import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.util.*;
import java.lang.*;
public class UI extends JFrame {
private Usage usage;
private JFrame frame;
private JTextField c_local_field;
private JTextField c_diff_field;
private JTextField c_we_field;
private JTextField c_ee_field;
private JTextField c_usa_field;
private JTextField c_asia_field;
private JTextField c_af_field;
private JTextField c_0800_field;
private JTextField c_vMail_field;
//MB
private JTextField mb_local_field;
private JTextField mb_we_field;
private JTextField mb_ee_field;
private JTextField mb_usa_field;
private JTextField mb_asia_field;
private JTextField mb_af_field;
//PM
private JTextField pm_local_field;
private JTextField pm_diff_field;
private JTextField pm_we_field;
private JTextField pm_ee_field;
private JTextField pm_usa_field;
private JTextField pm_asia_field;
private JTextField pm_af_field;
//Text
private JTextField t_local_field;
private JTextField t_diff_field;
private JTextField t_we_field;
private JTextField t_ee_field;
private JTextField t_usa_field;
private JTextField t_asia_field;
private JTextField t_af_field;
private JTextField t_0800_field;
//Video Call
private JTextField vc_af_field;
private JTextField vc_diff_field;
private JTextField vc_asia_field;
private JTextField vc_ee_field;
private JTextField vc_local_field;
private JTextField vc_usa_field;
private JTextField vc_we_field;
//Video Message
private JTextField vm_local_field;
private JTextField vm_diff_field;
private JTextField vm_we_field;
private JTextField vm_ee_field;
private JTextField vm_usa_field;
private JTextField vm_asia_field;
private JTextField vm_af_field;
//Return Call
private JTextField rc_local_field;
private JTextField rc_diff_field;
private JTextField rc_we_field;
private JTextField rc_ee_field;
private JTextField rc_usa_field;
private JTextField rc_asia_field;
private JTextField rc_af_field;
//Cheapest Plan
private JTextField answer;
//The Enter button used to find out what the cheapest plan is
private JButton enter;
public UI() {
makeG();
}
/**
* This method creates a Graphical User Interface.
*/
private void makeG() {
frame = new JFrame(" ");
Container contentPane = frame.getContentPane();
contentPane.setLayout(new GridLayout(10, 10, 15, 15));
mBar(frame);
JLabel nothing = new JLabel();
contentPane.add(nothing);
contentPane.add(new JLabel(" Local"));
contentPane.add(new JLabel(" Different Network"));
contentPane.add(new JLabel(" Western Europe"));
contentPane.add(new JLabel(" Eastern Europe"));
contentPane.add(new JLabel(" USA and Canada"));
contentPane.add(new JLabel(" Asia"));
contentPane.add(new JLabel(" Africa"));
contentPane.add(new JLabel(" 0800 Num"));
contentPane.add(new JLabel(" Voice Mail"));
contentPane.add(new JLabel(" Calls"));
JTextField c_local_field = new JTextField();
contentPane.add(c_local_field);
JTextField c_diff_field = new JTextField();
contentPane.add(c_diff_field);
JTextField c_we_field = new JTextField();
contentPane.add(c_we_field);
JTextField c_ee_field = new JTextField();
contentPane.add(c_ee_field);
JTextField c_usa_field = new JTextField();
contentPane.add(c_usa_field);
JTextField c_asia_field = new JTextField();
contentPane.add(c_asia_field);
JTextField c_af_field = new JTextField();
contentPane.add(c_af_field);
JTextField c_0800_field = new JTextField();
contentPane.add(c_0800_field);
JTextField c_vMail_field = new JTextField();
contentPane.add(c_vMail_field);
contentPane.add(new JLabel(" Texts"));
JTextField t_local_field = new JTextField();
contentPane.add(t_local_field);
JTextField t_diff_field = new JTextField();
contentPane.add(t_diff_field);
JTextField t_we_field = new JTextField();
contentPane.add(t_we_field);
JTextField t_ee_field = new JTextField();
contentPane.add(t_ee_field);
JTextField t_usa_field = new JTextField();
contentPane.add(t_usa_field);
JTextField t_asia_field = new JTextField();
contentPane.add(t_asia_field);
JTextField t_af_field = new JTextField();
contentPane.add(t_af_field);
JTextField t_0800_field = new JTextField();
contentPane.add(t_0800_field);
contentPane.add(new JLabel());
contentPane.add(new JLabel(" Video Calls"));
JTextField vc_local_field = new JTextField();
contentPane.add(vc_local_field);
JTextField vc_diff_field = new JTextField();
contentPane.add(vc_diff_field);
JTextField vc_we_field = new JTextField();
contentPane.add(vc_we_field);
JTextField vc_ee_field = new JTextField();
contentPane.add(vc_ee_field);
JTextField vc_usa_field = new JTextField();
contentPane.add(vc_usa_field);
JTextField vc_asia_field = new JTextField();
contentPane.add(vc_asia_field);
JTextField vc_af_field = new JTextField();
contentPane.add(vc_af_field);
contentPane.add(new JLabel());
contentPane.add(new JLabel());
contentPane.add(new JLabel(" MB"));
JTextField mb_local_field = new JTextField();
contentPane.add(mb_local_field);
JTextField mb_diff_field = new JTextField();
contentPane.add(mb_diff_field);
JTextField mb_we_field = new JTextField();
contentPane.add(mb_we_field);
JTextField mb_ee_field = new JTextField();
contentPane.add(mb_ee_field);
JTextField mb_usa_field = new JTextField();
contentPane.add(mb_usa_field);
JTextField mb_asia_field = new JTextField();
contentPane.add(mb_asia_field);
JTextField mb_af_field = new JTextField();
contentPane.add(mb_af_field);
contentPane.add(new JLabel());
contentPane.add(new JLabel());
contentPane.add(new JLabel(" Picture Messages"));
JTextField pm_local_field = new JTextField();
contentPane.add(pm_local_field);
JTextField pm_diff_field = new JTextField();
contentPane.add(pm_diff_field);
JTextField pm_we_field = new JTextField();
contentPane.add(pm_we_field);
JTextField pm_ee_field = new JTextField();
contentPane.add(pm_ee_field);
JTextField pm_usa_field = new JTextField();
contentPane.add(pm_usa_field);
JTextField pm_asia_field = new JTextField();
contentPane.add(pm_asia_field);
JTextField pm_af_field = new JTextField();
contentPane.add(pm_af_field);
contentPane.add(new JLabel());
contentPane.add(new JLabel());
contentPane.add(new JLabel(" Video Messages"));
JTextField vm_local_field = new JTextField();
contentPane.add(vm_local_field);
JTextField vm_diff_field = new JTextField();
contentPane.add(vm_diff_field);
JTextField vm_we_field = new JTextField();
contentPane.add(vm_we_field);
JTextField vm_ee_field = new JTextField();
contentPane.add(vm_ee_field);
JTextField vm_usa_field = new JTextField();
contentPane.add(vm_usa_field);
JTextField vm_asia_field = new JTextField();
contentPane.add(vm_asia_field);
JTextField vm_af_field = new JTextField();
contentPane.add(vm_af_field);
contentPane.add(new JLabel(" "));
contentPane.add(new JLabel(" "));
contentPane.add(new JLabel(" Receiving Calls"));
JTextField rc_local_field = new JTextField();
contentPane.add(rc_local_field);
JTextField rc_diff_field = new JTextField();
contentPane.add(rc_diff_field);
JTextField rc_we_field = new JTextField();
contentPane.add(rc_we_field);
JTextField rc_ee_field = new JTextField();
contentPane.add(rc_ee_field);
JTextField rc_usa_field = new JTextField();
contentPane.add(rc_usa_field);
JTextField rc_asia_field = new JTextField();
contentPane.add(rc_asia_field);
JTextField rc_af_field = new JTextField();
contentPane.add(rc_af_field);
contentPane.add(new JLabel());
contentPane.add(new JLabel());
contentPane.add(new JLabel());
contentPane.add(new JLabel());
contentPane.add(new JLabel());
contentPane.add(new JLabel());
JButton enter = new JButton("Enter");
contentPane.add(enter);
contentPane.add(new JLabel());
contentPane.add(new JLabel());
contentPane.add(new JLabel());
contentPane.add(new JLabel());
contentPane.add(new JLabel());
contentPane.add(new JLabel());
contentPane.add(new JLabel());
contentPane.add(new JLabel());
contentPane.add(new JLabel("Answer:"));
JTextField answer = new JTextField();
contentPane.add(answer);
contentPane.add(new JLabel());
contentPane.add(new JLabel());
contentPane.add(new JLabel());
contentPane.add(new JLabel());
mBar(frame);
frame.pack();
frame.setVisible(true);
}
public void mBar(JFrame frame) {
final int SHORTCUT_MASK =
Toolkit.getDefaultToolkit().getMenuShortcutKeyMask();
JMenuBar menubar = new JMenuBar();
frame.setJMenuBar(menubar);
JMenu menu;
JMenuItem item;
// create the File menu
menu = new JMenu("File");
menubar.add(menu);
menu = new JMenu("Help");
menubar.add(menu);
}
/**
* This Collection of inner classed store the values entered in the text filed in A usage object. They
* also make sure theat the program users are only allowed to enter Integer values if the try to enter a
* different type of value they will get an error message
*/
public class C_S_Net {
public void actionPerformed(ActionEvent evt) {
try {
// Normal calls
usage.c_S_Network = Integer.parseInt(c_local_field.getText());
} catch (Exception a) {
JOptionPane.showInternalMessageDialog(c_local_field, "Wrong Data Type Please Enter an Integer", "Error", JOptionPane.ERROR_MESSAGE);
return;
}
}
}
public class C_D_Net {
public void actionPerformed(ActionEvent evt) {
try {
// Normal calls
usage.c_D_Network = Integer.parseInt(c_diff_field.getText());
} catch (Exception a) {
JOptionPane.showInternalMessageDialog(c_diff_field, "Wrong Data Type Please Enter an Integer", "Error", JOptionPane.ERROR_MESSAGE);
return;
}
}
}
public class C_0800_Net {
public void actionPerformed(ActionEvent evt) {
try {
// Normal calls
usage.c_0800Num = Integer.parseInt(c_0800_field.getText());
} catch (Exception a) {
JOptionPane.showInternalMessageDialog(c_diff_field, "Wrong Data Type Please Enter an Integer", "Error", JOptionPane.ERROR_MESSAGE);
return;
}
}
}
public class C_Vmail {
public void actionPerformed(ActionEvent evt) {
try {
// Normal calls
usage.c_VoiceMail = Integer.parseInt(c_vMail_field.getText());
} catch (Exception a) {
JOptionPane.showInternalMessageDialog(c_vMail_field, "Wrong Data Type Please Enter an Integer", "Error", JOptionPane.ERROR_MESSAGE);
return;
}
}
}
public class C_We {
public void actionPerformed(ActionEvent evt) {
try {
usage.c_WEurope = Integer.parseInt(c_we_field.getText());
} catch (Exception g) {
JOptionPane.showInternalMessageDialog(c_we_field, "Wrong Data Type Please Enter an Integer", "Error", JOptionPane.ERROR_MESSAGE);
return;
}
}
public class C_EE {
public void actionPerformed(ActionEvent evt) {
try {
usage.c_EEurope = Integer.parseInt(c_ee_field.getText());
} catch (Exception m) {
JOptionPane.showInternalMessageDialog(c_ee_field, "Wrong Data Type Please Enter an Integer", "Error", JOptionPane.ERROR_MESSAGE);
return;
}
}
}
public class c_USA {
public void actionPerformed(ActionEvent evt) {
try {
usage.c_USA_Canada = Integer.parseInt(c_asia_field.getText());
} catch (Exception s) {
JOptionPane.showInternalMessageDialog(c_asia_field, "Wrong Data Type Please Enter an Integer", "Error", JOptionPane.ERROR_MESSAGE);
return;
}
}
}
}
public class C_As {
public void actionPerformed(ActionEvent evt) {
try {
usage.c_Asia = Integer.parseInt(c_asia_field.getText());
} catch (Exception s) {
JOptionPane.showInternalMessageDialog(c_asia_field, "Wrong Data Type Please Enter an Integer", "Error", JOptionPane.ERROR_MESSAGE);
return;
}
}
}
public class C_Af {
public void actionPerformed(ActionEvent evt) {
try {
usage.c_Africa = Integer.parseInt(c_af_field.getText());
} catch (Exception a) {
JOptionPane.showInternalMessageDialog(c_af_field, "Wrong Data Type Please Enter an Integer", "Error", JOptionPane.ERROR_MESSAGE);
return;
}
}
}
public class VC_S_Net {
public void actionPerformed(ActionEvent evt) {
try {
usage.vc_S_Network = Integer.parseInt(vc_local_field.getText());
} catch (Exception b) {
JOptionPane.showInternalMessageDialog(vc_local_field, "Wrong Data Type Please Enter an Integer", "Error", JOptionPane.ERROR_MESSAGE);
return;
}
}
}
public class VC_WE {
public void actionPerformed(ActionEvent evt) {
try {
usage.vc_WEurope = Integer.parseInt(vc_we_field.getText());
} catch (Exception h) {
JOptionPane.showInternalMessageDialog(vc_we_field, "Wrong Data Type Please Enter an Integer", "Error", JOptionPane.ERROR_MESSAGE);
return;
}
}
}
public class VC_EE {
public void actionPerformed(ActionEvent evt) {
try {
usage.vc_EEurope = Integer.parseInt(vc_ee_field.getText());
} catch (Exception n) {
JOptionPane.showInternalMessageDialog(vc_ee_field, "Wrong Data Type Please Enter an Integer", "Error", JOptionPane.ERROR_MESSAGE);
return;
}
}
}
public class VC_USA {
public void actionPerformed(ActionEvent evt) {
try {
usage.vc_USA_Canada = Integer.parseInt(vc_asia_field.getText());
} catch (Exception t) {
JOptionPane.showInternalMessageDialog(vc_asia_field, "Wrong Data Type Please Enter an Integer", "Error", JOptionPane.ERROR_MESSAGE);
return;
}
}
}
public class VC_As {
public void actionPerformed(ActionEvent evt) {
try {
usage.vc_Asia = Integer.parseInt(vc_usa_field.getText());
} catch (Exception t) {
JOptionPane.showInternalMessageDialog(vc_usa_field, "Wrong Data Type Please Enter an Integer", "Error", JOptionPane.ERROR_MESSAGE);
return;
}
}
}
public class VC_Af {
public void actionPerformed(ActionEvent evt) {
try {
usage.vc_Africa = Integer.parseInt(vc_af_field.getText());
} catch (Exception b) {
JOptionPane.showInternalMessageDialog(vc_af_field, "Wrong Data Type Please Enter an Integer", "Error", JOptionPane.ERROR_MESSAGE);
return;
}
}
}
public class T_Lo {
public void actionPerformed(ActionEvent evt) {
try {
usage.t_Local = Integer.parseInt(t_local_field.getText());
} catch (Exception c) {
JOptionPane.showInternalMessageDialog(t_local_field, "Wrong Data Type Please Enter an Integer", "Error", JOptionPane.ERROR_MESSAGE);
return;
}
}
}
public class T_WE {
public void actionPerformed(ActionEvent evt) {
try {
usage.t_WEurope = Integer.parseInt(t_we_field.getText());
} catch (Exception i) {
JOptionPane.showInternalMessageDialog(t_we_field, "Wrong Data Type Please Enter an Integer", "Error", JOptionPane.ERROR_MESSAGE);
return;
}
}
}
public class T_USA {
public void actionPerformed(ActionEvent evt) {
try {
usage.t_USA_Canada = Integer.parseInt(t_asia_field.getText());
} catch (Exception u) {
JOptionPane.showInternalMessageDialog(t_asia_field, "Wrong Data Type Please Enter an Integer", "Error", JOptionPane.ERROR_MESSAGE);
return;
}
}
}
public class T_As {
public void actionPerformed(ActionEvent evt) {
try {
usage.t_Asia = Integer.parseInt(t_usa_field.getText());
} catch (Exception u) {
JOptionPane.showInternalMessageDialog(t_usa_field, "Wrong Data Type Please Enter an Integer", "Error", JOptionPane.ERROR_MESSAGE);
return;
}
}
}
public class T_Af {
public void actionPerformed(ActionEvent evt) {
try {
usage.t_Africa = Integer.parseInt(t_af_field.getText());
} catch (Exception c) {
JOptionPane.showInternalMessageDialog(t_af_field, "Wrong Data Type Please Enter an Integer", "Error", JOptionPane.ERROR_MESSAGE);
return;
}
}
}
public class MB_loc {
public void actionPerformed(ActionEvent evt) {
try {
usage.mb_Local = Integer.parseInt(mb_local_field.getText());
} catch (Exception d) {
JOptionPane.showInternalMessageDialog(mb_local_field, "Wrong Data Type Please Enter an Integer", "Error", JOptionPane.ERROR_MESSAGE);
return;
}
}
}
public class MB_We {
public void actionPerformed(ActionEvent evt) {
try {
usage.mb_WEurope = Integer.parseInt(mb_we_field.getText());
} catch (Exception j) {
JOptionPane.showInternalMessageDialog(mb_we_field, "Wrong Data Type Please Enter an Integer", "Error", JOptionPane.ERROR_MESSAGE);
return;
}
}
}
public class MB_Ee {
public void actionPerformed(ActionEvent evt) {
try {
usage.mb_EEurope = Integer.parseInt(mb_ee_field.getText());
} catch (Exception p) {
JOptionPane.showInternalMessageDialog(mb_ee_field, "Wrong Data Type Please Enter an Integer", "Error", JOptionPane.ERROR_MESSAGE);
return;
}
}
}
public class MB_USA {
public void actionPerformed(ActionEvent evt) {
try {
usage.mb_USA_Canada = Integer.parseInt(mb_usa_field.getText());
} catch (Exception v) {
JOptionPane.showInternalMessageDialog(mb_usa_field, "Wrong Data Type Please Enter an Integer", "Error", JOptionPane.ERROR_MESSAGE);
return;
}
}
}
public class MB_As {
public void actionPerformed(ActionEvent evt) {
try {
usage.mb_Asia = Integer.parseInt(mb_asia_field.getText());
} catch (Exception v) {
JOptionPane.showInternalMessageDialog(mb_asia_field, "Wrong Data Type Please Enter an Integer", "Error", JOptionPane.ERROR_MESSAGE);
return;
}
}
}
public class MB_af {
public void actionPerformed(ActionEvent evt) {
try {
usage.mb_Africa = Integer.parseInt(mb_af_field.getText());
} catch (Exception d) {
JOptionPane.showInternalMessageDialog(mb_af_field, "Wrong Data Type Please Enter an Integer", "Error", JOptionPane.ERROR_MESSAGE);
return;
}
}
}
public class PM_lo {
public void actionPerformed(ActionEvent evt) {
try {
usage.pm_Local = Integer.parseInt(pm_local_field.getText());
} catch (Exception e) {
JOptionPane.showInternalMessageDialog(pm_local_field, "Wrong Data Type Please Enter an Integer", "Error", JOptionPane.ERROR_MESSAGE);
return;
}
}
}
public class PM_We {
public void actionPerformed(ActionEvent evt) {
try {
usage.pm_WEurope = Integer.parseInt(pm_we_field.getText());
} catch (Exception k) {
JOptionPane.showInternalMessageDialog(pm_we_field, "Wrong Data Type Please Enter an Integer", "Error", JOptionPane.ERROR_MESSAGE);
return;
}
}
}
public class PM_Ee {
public void actionPerformed(ActionEvent evt) {
try {
usage.pm_EEurope = Integer.parseInt(pm_ee_field.getText());
} catch (Exception q) {
JOptionPane.showInternalMessageDialog(pm_ee_field, "Wrong Data Type Please Enter an Integer", "Error", JOptionPane.ERROR_MESSAGE);
return;
}
}
}
public class PM_USA {
public void actionPerformed(ActionEvent evt) {
try {
usage.pm_USA_Canada = Integer.parseInt(pm_usa_field.getText());
} catch (Exception w) {
JOptionPane.showInternalMessageDialog(pm_usa_field, "Wrong Data Type Please Enter an Integer", "Error", JOptionPane.ERROR_MESSAGE);
return;
}
}
}
public class PM_As {
public void actionPerformed(ActionEvent evt) {
try {
usage.pm_Asia = Integer.parseInt(pm_asia_field.getText());
} catch (Exception w) {
JOptionPane.showInternalMessageDialog(pm_asia_field, "Wrong Data Type Please Enter an Integer", "Error", JOptionPane.ERROR_MESSAGE);
return;
}
}
}
public class PM_Af {
public void actionPerformed(ActionEvent evt) {
try {
usage.pm_Africa = Integer.parseInt(pm_af_field.getText());
} catch (Exception e) {
JOptionPane.showInternalMessageDialog(pm_af_field, "Wrong Data Type Please Enter an Integer", "Error", JOptionPane.ERROR_MESSAGE);
return;
}
}
}
public class RC_We {
public void actionPerformed(ActionEvent evt) {
try {
usage.rc_WEurope = Integer.parseInt(rc_we_field.getText());
} catch (Exception g) {
JOptionPane.showInternalMessageDialog(rc_we_field, "Wrong Data Type Please Enter an Integer", "Error", JOptionPane.ERROR_MESSAGE);
return;
}
}
}
public class RC_Ee {
public void actionPerformed(ActionEvent evt) {
try {
usage.rc_EEurope = Integer.parseInt(rc_ee_field.getText());
} catch (Exception g) {
JOptionPane.showInternalMessageDialog(rc_ee_field, "Wrong Data Type Please Enter an Integer", "Error", JOptionPane.ERROR_MESSAGE);
return;
}
}
}
public class RC_USA {
public void actionPerformed(ActionEvent evt) {
try {
usage.rc_USA_Canada = Integer.parseInt(rc_usa_field.getText());
} catch (Exception g) {
JOptionPane.showInternalMessageDialog(rc_usa_field, "Wrong Data Type Please Enter an Integer", "Error", JOptionPane.ERROR_MESSAGE);
return;
}
}
public class RC_As {
public void actionPerformed(ActionEvent evt) {
try {
usage.rc_Asia = Integer.parseInt(c_asia_field.getText());
} catch (Exception s) {
JOptionPane.showInternalMessageDialog(c_asia_field, "Wrong Data Type Please Enter an Integer", "Error", JOptionPane.ERROR_MESSAGE);
return;
}
}
}
public class RC_Af {
public void actionPerformed(ActionEvent evt) {
try {
usage.rc_Africa = Integer.parseInt(rc_af_field.getText());
} catch (Exception a) {
JOptionPane.showInternalMessageDialog(rc_af_field, "Wrong Data Type Please Enter an Integer", "Error", JOptionPane.ERROR_MESSAGE);
return;
}
}
}
}
}