Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: Help with GUI

  1. #1
    Junior Member
    Join Date
    Aug 2011
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Help with GUI

    Hello I am trying to get my GUI to create a Usage Object after the user has entered some data. The data are parameters used that make up a usage object. I want call a method on it and then do some sort of calculation once the user has pressed the enter button. Sorry for the classes for being so massive but the user needs to enter a lot of data in order to get the right result. The first class is the gui class and at the moment simply creates a gui. I have a number of inner class that assign the data stored in the text field to the corresponding field in the Usage class. Usage class consists of fields and return statements so not much going on there.

    Any help would be great thank you for your time
     
    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;
                    }
     
                }
            }
     
        }
    }



    import java.util.*;
    public class Usage {
     
        private int cost; 
        // Made
        public int c_S_Network;
        public int c_D_Network;
        public int c_VoiceMail;
        public int c_0800Num;
        public int c_WEurope;
        public int c_EEurope;
        public int c_USA_Canada;
        public int c_Asia;
        public int c_Africa; 
        //Video  Made
        public int vc_S_Network;
        public int vc_DNetwork;
        public int vc_WEurope;
        public int vc_EEurope;
        public int vc_USA_Canada;
        public int vc_Asia;
        public int vc_Africa; 
        // Recieved
        public int rc_WEurope;
        public int rc_EEurope;
        public int rc_USA_Canada;
        public int rc_Asia;
        public int rc_Africa;
        //Texts Sent
        public int t_Local;
        public int t_WEurope;
        public int t_EEurope;
        public int t_USA_Canada;
        public int t_Asia;
        public int t_Africa;
        //MB 
        public int mb_Local;
        public int mb_WEurope;
        public int mb_EEurope;
        public int mb_USA_Canada;
        public int mb_Asia;
        public int mb_Africa;
        //Picture Messages  
        public int pm_Local;
        public int pm_WEurope;
        public int pm_EEurope;
        public int pm_USA_Canada;
        public int pm_Asia;
        public int pm_Africa; 
        //Video Messages .
        public int vm_Local;
        public int vm_WEurope;
        public int vm_EEurope;
        public int vm_USA_Canada;
        public int vm_Asia;
        public int vm_Africa;
     
        public Usage ( int the_c_S_Network, int the_c_D_Network, int the_c_VoiceMail, 
        int the_c_0800Num, int the_c_WEurope,
        int the_c_EEurope, int the_c_USA_Canada, int the_c_Asia, int the_c_Africa,
        int the_vc_S_Network, int the_vc_DNetwork, int  the_vc_WEurope, 
        int the_vc_EEurope, int the_vc_USA_Canada, 
        int the_vc_Asia, int the_vc_Africa,
        int the_rc_WEurope, int the_rc_EEurope, int the_rc_USA_Canada, int the_rc_Africa,
        int the_t_Local, int the_t_WEurope, int the_t_EEurope, int the_t_Asia, int the_t_Africa,
        int the_mb_Local, int the_mb_WEurope, int the_mb_EEurope, int the_mb_USA_Canada,
        int the_mb_Asia,int the_mb_Africa, 
        int the_pm_Local, int the_pm_WEurope,  int the_pm_EEurope, int the_pm_USA_Canada,
        int the_pm_Asia, int the_pm_Africa, 
        int the_vm_Local, int the_vm_WEurope,int the_vm_EEurope, int the_vm_USA_Canada,
        int the_vm_Asia, int the_vm_Africa )
        { 
            // Made
            c_S_Network = the_c_S_Network;
            c_D_Network = the_c_D_Network;
            c_VoiceMail = the_c_VoiceMail;
            c_0800Num = the_c_0800Num;
            c_WEurope = the_c_WEurope;
            c_EEurope = the_c_EEurope;
            c_USA_Canada = the_c_USA_Canada;
            c_Asia =  the_c_Asia;
            c_Africa = the_c_Africa;
            //Video  Made
            vc_S_Network = the_vc_S_Network;
            vc_DNetwork = the_vc_DNetwork;
            vc_WEurope = the_vc_WEurope;
            vc_EEurope = the_vc_EEurope;
            vc_USA_Canada = the_vc_USA_Canada;
            vc_Asia = the_vc_Asia;
            vc_Africa = the_vc_Africa;
            // Recieved
            rc_WEurope = the_rc_WEurope;
            rc_EEurope  = the_rc_EEurope;
            rc_USA_Canada  = the_rc_USA_Canada;
            rc_Asia = the_rc_USA_Canada;
            rc_Africa = the_rc_Africa;
            //Texts Sent
            t_Local = the_t_Local;
            t_WEurope = the_t_WEurope;
            t_EEurope = the_t_EEurope;
            t_Asia = the_t_Asia;
            t_Africa = the_t_Africa;
            //MB 
            mb_Local = the_mb_Local;
            mb_WEurope = the_mb_WEurope;
            mb_EEurope = the_mb_EEurope;
            mb_USA_Canada = the_mb_USA_Canada;
            mb_Asia = the_mb_Asia;
            mb_Africa = the_mb_Africa;
            //Picture Messages  
            pm_Local = the_pm_Local;
            pm_WEurope = the_pm_WEurope;
            pm_EEurope = the_pm_EEurope;
            pm_USA_Canada = the_pm_USA_Canada;
            pm_Asia = the_pm_Asia;
            pm_Africa = the_pm_Africa;
            //Video Messages .
            vm_Local = the_vm_Local;
            vm_WEurope = the_vm_WEurope;
            vm_EEurope = the_vm_EEurope;
            vm_USA_Canada = the_vm_USA_Canada;
            vm_Asia = the_vm_Asia;
            vm_Africa = the_vm_Africa;
     
        }
     
     
        public int return_c_S_Network()
        {
            return c_S_Network;
        }
     
        public int return_c_D_Network()
        {
            return c_D_Network;
        }
     
        public int return_c_VoiceMail()
        {
            return c_VoiceMail;
        }
     
        public int return_c_0800Num()
        {
            return c_0800Num;
        }
     
        public int return_c_WEurope()
        {
            return c_WEurope;
        }
     
        public int return_c_EEurope()
        {
            return c_EEurope;
        }
     
        public int return_c_USA_Canada()
        {
            return c_USA_Canada;
        }
     
        public int return_c_Asia()
        {
            return c_Asia;
        }
     
        public int return_c_Africa()
        {
            return c_Africa;
        }
     
        //Video  Made
        public int return_vc_S_Network()
        {
            return vc_S_Network;
        }
     
        public int return_vc_DNetwork()
        {
            return vc_DNetwork;
        }
     
        public int return_vc_WEurope()
        {
            return vc_WEurope;
        }
     
        public int return_vc_EEurope()
        {
            return vc_EEurope;
        }
     
        public int return_vc_USA_Canada()
        {
            return vc_USA_Canada;
        }
     
        public int return_vc_Asia()
        {
            return vc_Asia;
        }
     
        public int return_vc_Africa()
        {
            return vc_Africa;
        }
     
        // Recieved
        public int return_rc_WEurope()
        {
            return rc_WEurope;
        }
     
        public int return_rc_EEurope()
        {
            return rc_EEurope;
        }
     
        public int return_rc_USA_Canada()
        {
            return rc_USA_Canada;
        }
     
        public int return_rc_Asia()
        {
            return rc_Asia;
        }
     
        public int return_rc_Africa()
        {
            return rc_Africa;
        }
        //Texts Sent
        public int return_t_Local()
        {
            return t_Local;
        }
     
        public int return_t_WEurope()
        {
            return t_WEurope;
        }
     
        public int return_t_EEurope()
        {
            return t_EEurope;
        }
     
        public int return_t_USA_Canada()
        {
            return t_USA_Canada;
        }
     
        public int return_t_Asia()
        {
            return t_Asia;
        }
     
        public int return_t_Africa()
        {
            return t_Africa;
        }
     
        //MB 
        public int return_mb_Local()
        {
            return mb_Local;
        }
     
        public int return_mb_WEurope()
        {
            return mb_WEurope;
        }
     
        public int return_mb_EEurope()
        {
            return mb_EEurope;
        }
     
        public int return_mb_USA_Canada()
        {
            return mb_USA_Canada;
        }
     
        public int return_mb_Asia()
        {
            return mb_Asia;
        }
     
        public int return_mb_Africa()
        {
            return mb_Africa;
        }
     
        //Picture Messages  
        public int return_pm_Local()
        {
            return pm_Local;
        }
     
        public int return_pm_WEurope()
        {
            return pm_WEurope;
        }
     
        public int return_pm_EEurope()
        {
            return pm_EEurope;
        }
     
        public int return_pm_USA_Canda()
        {
            return pm_USA_Canada;
        }
     
        public int return_pm_Asia()
        {
            return pm_Asia;
        }
     
        public int return_pm_Africa()
        {
            return pm_Africa;
        }
     
        //Video Messages .
        public int return_vm_Local()
        {
            return vm_Local;
        }
     
        public int return_vm_WEurope()
        {
            return vm_WEurope;
        }
     
        public int return_vm_EEurope()
        {
            return vm_WEurope;
        }
     
        public int return_vm_USA_Canada()
        {
            return vm_USA_Canada;
        }
     
        public int return_vm_Asia()
        {
            return vm_Asia;
        }
     
        public int return_vm_Africa()
        {
            return vm_Africa;
        }
    }


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: Help with GUI

    I am trying to get my GUI to create a Usage Object after the user has entered some data. The data are parameters used that make up a usage object. I want call a method on it
    Can you describe what problems you are having?
    Do you have a button that should call a method when pressed?
    Or do you need to get a reference to an object so you can call its method?
    Or what?