0

I am new to packaging, and pretty new to programming, and I ran into an issue where the VM is not able to find an internal class being created by one of my class objects.

A quick background on this project, it is a piggy bank app I am putting together for my kids. The program works fine in the command line, but once I package it I have this error. I would like to package it so the kids can open it as needed on the desktop. I packaged it using the following command line:

java cmf Bank.mf BankMain.class Login.class BankGUI.class BankGUI$1.class AccountGUI.class AccountGUI$1.class AccountGUI$1.class Account.class

The problem that comes up is inside BankGUI.class I have a Action Listener function that is not part of the class object, but it is called by the class object. I tried making it a class method, but this made no difference.

The intent of this code is to open a login screen, the child can type in their user name and password, the system either does nothing if the information is not correct, or it opens a AccountGUI object based on the credentials and closes the original BankGUI object. It crossed my mind that making 'respond' a static method might help this issue, but on second thought (and a trial) it makes sense that it has no bearing on the fact that a BankGUI is opening an internal class. I feel that the problem has to do with closing the original BankGUI object while the remaining objects are open, but I can't see where or how, and there are no references online that have helped. Any insight would be appreciated!

    ...boolean login = false;

    Login log = new Login();

    Font f = new Font("Helvetica", Font.BOLD, 30);
    Font f2 = new Font("Helvetica", Font.BOLD, 60);

    JPanel mainPanel = new JPanel();
    mainPanel.setBackground(Color.BLACK);
    add(mainPanel);

    JPanel panel = new JPanel(new GridLayout(6, 1));
    mainPanel.add(panel, BorderLayout.CENTER);
    panel.setBackground(Color.BLACK);

    JPanel blank = new JPanel();
    blank.setBackground(Color.BLACK);
    panel.add(blank);

    JPanel blank1 = new JPanel();
    blank1.setBackground(Color.BLACK);
    panel.add(blank1);


    JPanel welcomePanel = new JPanel();
    welcomePanel.setBackground(Color.BLACK);
    panel.add(welcomePanel);

    JLabel welcomeLabel = new JLabel("Please log into your account");
    welcomeLabel.setFont(f);
    welcomeLabel.setBackground(Color.BLACK);
    welcomeLabel.setForeground(Color.WHITE);
    welcomePanel.add(welcomeLabel);


    JPanel user = new JPanel();
    user.setLayout(new BorderLayout());
    user.setBackground(Color.BLACK);
    panel.add(user);

    JLabel name = new JLabel("USER NAME:     ");
    name.setFont(f);
    name.setBackground(Color.BLACK);
    name.setForeground(Color.WHITE);
    name.setBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null));

    JTextField nInput = new JTextField();
    nInput.setFont(f2);
    nInput.setBackground(Color.BLACK);
    nInput.setForeground(Color.WHITE);


    JPanel pass = new JPanel();
    pass.setLayout(new BorderLayout());
    pass.setBackground(Color.BLACK);
    panel.add(pass);


    JLabel password = new JLabel("PASSWORD:     ");
    password.setFont(f);
    password.setBackground(Color.BLACK);
    password.setForeground(Color.WHITE);
    password.setBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null));


    JPasswordField pw = new JPasswordField(10);
    pw.setFont(f2);
    pw.setBackground(Color.BLACK);
    pw.setForeground(Color.WHITE);

    panel.add(blank);

    JButton submit = new JButton("SUBMIT");
    submit.setFont(f);
    submit.setBackground(Color.GRAY);
    submit.setForeground(Color.WHITE);

    user.add(name, BorderLayout.WEST);
    user.add(nInput, BorderLayout.CENTER);
    pass.add(password, BorderLayout.WEST);
    pass.add(pw, BorderLayout.CENTER);
    panel.add(submit);


    respond(submit, nInput, pw, log, login);




    }


    public void respond(JButton b, JTextField tf, JPasswordField pf, Login log, boolean login) {
     b.addActionListener(new ActionListener() {

      public void actionPerformed(ActionEvent e) {
       String s = e.getActionCommand();

       switch (s) {
        case ("SUBMIT"):
         log.setUser(tf.getText());
         char[] password = pf.getPassword();
         String pw = String.valueOf(password);
         log.setPassword(pw);
         if (log.getVerification()) {

          AccountGUI open = new AccountGUI(tf.getText(), pw);
          open.setVisible(true);

          dispose();
         }
         break;
       }



      }
     });
    }

    }
Mohammed Siddiq
  • 477
  • 4
  • 16

0 Answers0