updated code to follow brief's format better and tested save and open functionality
This commit is contained in:
1 parent
559d346c58
commit
44f5279d36
4 files changed
+19
-29
No files matched your search
@@ -7,12 +7,12 @@ import cvbuilder.model.UserGroup;
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
|
||||
|
||||
|
||||
public class MainViewer {
|
||||
|
||||
private UserGroup userGroup;
|
||||
private final UserGroup userGroup;
|
||||
|
||||
public MainViewer() {
|
||||
userGroup = UserGroup.getInstance();
|
||||
@@ -160,24 +160,18 @@ public class MainViewer {
|
||||
// Add some spacing
|
||||
entryPanel.add(Box.createHorizontalStrut(5));
|
||||
|
||||
// Create Delete button
|
||||
// Create delete button
|
||||
JButton deleteButton = new JButton("Delete");
|
||||
deleteButton.addActionListener(e -> {
|
||||
int confirm = JOptionPane.showConfirmDialog(panel,
|
||||
"Are you sure you want to delete this entry?",
|
||||
"Confirm Delete", JOptionPane.YES_NO_OPTION);
|
||||
// Remove the user without confirmation
|
||||
userGroup.getUsers().remove(userIndex);
|
||||
|
||||
if (confirm == JOptionPane.YES_OPTION) {
|
||||
// Remove the user
|
||||
userGroup.getUsers().remove(userIndex);
|
||||
|
||||
// Refresh all panels
|
||||
JFrame frame = (JFrame) SwingUtilities.getWindowAncestor(panel);
|
||||
frame.getContentPane().removeAll();
|
||||
populateMainPanel(frame);
|
||||
frame.revalidate();
|
||||
frame.repaint();
|
||||
}
|
||||
// Refresh all panels
|
||||
JFrame frame = (JFrame) SwingUtilities.getWindowAncestor(panel);
|
||||
frame.getContentPane().removeAll();
|
||||
populateMainPanel(frame);
|
||||
frame.revalidate();
|
||||
frame.repaint();
|
||||
});
|
||||
entryPanel.add(deleteButton);
|
||||
|
||||
@@ -519,10 +513,7 @@ public class MainViewer {
|
||||
writer.println();
|
||||
}
|
||||
|
||||
JOptionPane.showMessageDialog(null,
|
||||
"CSV file saved successfully to " + filePath,
|
||||
"Save Successful",
|
||||
JOptionPane.INFORMATION_MESSAGE);
|
||||
// Success message removed
|
||||
|
||||
} catch (IOException e) {
|
||||
JOptionPane.showMessageDialog(null,
|
||||
@@ -532,5 +523,4 @@ public class MainViewer {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user