невозможно реализовать actionPerformed (ActionEvent) в ActionListener

Я делаю программу шифрования профиля с 2-мя шифрами. Я хочу иметь графический интерфейс с кнопками для шифрования, дешифрования и выхода.

Моя проблема связана с методом actionPerformed. Это должно вызвать исключение, которое генерирует outputStream. Это ошибка, которую я получаю, когда пытаюсь ее выполнить:

:53: error: actionPerformed(ActionEvent) in ProfileEncryption_2 cannot implement actionPerformed(ActionEvent) in ActionListener
public void actionPerformed (ActionEvent e) throws FileNotFoundException//When a button is clicked

У меня есть несколько решений, но я не уверен, как правильно их реализовать. Я мог бы поймать исключение и сделать что-нибудь с ним, но я не уверен, как и что. Я также мог бы проверить, существует ли файл, и если да, то вывод, но то, что я пробовал для этого, тоже не сработало.

   public void actionPerformed (ActionEvent e) throws Exception //When a button is clicked
   {
      if (e.getSource() == encrBtn)
      {
            menu.setVisible(false);
         createProfile();
         menu.setVisible(true);
      }
      else
      {
         if (e.getSource() == decrBtn)
         {
            menu.setVisible(false);
            viewProfile();
            menu.setVisible(true);
         }
         else
         {
            if (e.getSource() == exitBtn)
            {
               JOptionPane.showMessageDialog(null, "Goodbye!");
                    System.exit(0);
            }
         }
      }
   }

    //End of menu
    //Start of create/view section

   public static void createProfile() throws Exception //Create profile
   {
      String username = JOptionPane.showInputDialog("Enter your username.");
      String password, confirmPass, strEncrType;
      int intEncrType = 0, unlock = 0;
      do
      {
         password = JOptionPane.showInputDialog("Enter your password.\nIt must be more than 7 characters long.");
         confirmPass = JOptionPane.showInputDialog("Confirm password");
         if (password.equals(confirmPass) && (password.length() >= 7)) 
         {
            JOptionPane.showMessageDialog(null, "Passwords match!");
            unlock = 1;
         }
         else
         {
            if (!password.equals(confirmPass))
               JOptionPane.showMessageDialog(null, "Passwords do not match!");
            if (password.length() < 7)
               JOptionPane.showMessageDialog(null, "Password is not long enough!");
         }
      }
      while (unlock==0);
      do
      {
         strEncrType = JOptionPane.showInputDialog("Choose which encryption type you would prefer:\n1. Vigenère\n2. Erénegiv mod 4");
         if(!strEncrType.equals("1")&&!strEncrType.equals("2"))
            JOptionPane.showMessageDialog(null, "Invalid response, try again.");
      }
      while (!strEncrType.equals("1")&&!strEncrType.equals("2"));
      intEncrType = Integer.parseInt(strEncrType);
      String name = JOptionPane.showInputDialog("Enter your real name.");
      String phone = JOptionPane.showInputDialog("Enter your phone number.");
      String email = JOptionPane.showInputDialog("Enter your email.");
      String other = JOptionPane.showInputDialog("Enter notes/extra data you want stored.");
      String data = password + "-" + username + "-tester-" + name + "-" + phone + "-" + email + "-" + other + "-" + strEncrType;
      if (intEncrType ==1)
         data = encrypt1(data);
      else
         data = encrypt2(data);
      data = data + strEncrType;

        OutputStream output = new FileOutputStream(username + ".txt");
      byte buffer[] = data.getBytes();
      output.write(buffer);
      output.close();
   }

Ответы на вопрос(0)

Ваш ответ на вопрос