Я пытаюсь настроить свой код на тот момент, когда какой-либо ученик входит в систему, чтобы он мог просматривать свою собственную оценку.Я думал, как сейчас настроен мой код, чтобы каждый ученик мог просматривать свою оценку.Однако, независимо от того, какой студент входит в систему, они могут просматривать все текстовые файлы в текущем каталоге, которые мне не нужны.Есть ли что-то, что я делаю неправильно?
![First student is logged in (should only see hw 1)](https://i.stack.imgur.com/Wrejc.jpg)
![Student 2 is logged in (shouldn't be able to see hw1, but does)](https://i.stack.imgur.com/qkYJm.jpg)
// student text file, this opens the StudentPassword.txt file
StudentPassFile studacc = new StudentPassFile();
studacc.openFile();
studacc.read_file();
JButton btnNewButton = new JButton("View Grades");
btnNewButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
if (StudentPassFile.map.get(AccountLogin.user) != null && StudentPassFile.map.get(AccountLogin.user).equals(AccountLogin.passw)) // IF STUDENT ACCOUNT
{
AccountLogin.currentAccount = AccountLogin.user;
StudentPassFile.password = AccountLogin.passw;
FileSystemView fsv = new DirectoryRestrictedFileSystemView(new File("Grades"));
JFileChooser chooser = new JFileChooser(fsv.getHomeDirectory(),fsv);
chooser.showOpenDialog(null);
File f = chooser.getSelectedFile();
String nameFile = f.getAbsolutePath();
try {
FileReader reader = new FileReader(nameFile);
BufferedReader br = new BufferedReader(reader);
jTextArea1.read(br, null);
br.close();
jTextArea1.requestFocus();
}
catch(Exception e){
JOptionPane.showMessageDialog(null, e);
}
}
}
});