Skip to content

Commit 42b3a40

Browse files
committed
kak te
1 parent 9e46203 commit 42b3a40

9 files changed

+41
-33
lines changed

.vscode/settings.json

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"githubPullRequests.ignoredPullRequestBranches": [
3+
"main"
4+
],
5+
"java.project.referencedLibraries": [
6+
"lib/**/*.jar",
7+
"c:\\Users\\User\\Downloads\\mysql-connector-java-8.0.25.jar"
8+
]
9+
}

Entity/InterfaceGui/MainPage.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,16 @@ public MainPage(String userRole) {
2828
manageProductButton = new JButton("Manage Product");
2929
manageProductButton.setFont(new Font("Arial", Font.PLAIN, 14));
3030
manageProductButton.addActionListener(e -> {
31-
32-
dispose();
31+
new ProductMain();
32+
// dispose();
3333
});
3434

3535
manageEmployeeButton = new JButton("Manage Employee");
3636
manageEmployeeButton.setFont(new Font("Arial", Font.PLAIN, 14));
3737
manageEmployeeButton.setEnabled(userRole.equals("admin")); // Enable only for admin
3838
manageEmployeeButton.addActionListener(e -> {
3939
new ManageEmployeeGUI(); // Open Manage Employee GUI
40-
dispose();
40+
// dispose();
4141
});
4242

4343
manageMembershipButton = new JButton("Manage Membership");
@@ -48,7 +48,7 @@ public MainPage(String userRole) {
4848
addCartButton.setFont(new Font("Arial", Font.PLAIN, 14));
4949
addCartButton.addActionListener(e -> {
5050
new ShopManagementGUI().createAndShowGUI(); // Open Manage Employee GUI
51-
dispose();
51+
// dispose();
5252
});
5353
centerPanel.add(manageProductButton);
5454
centerPanel.add(manageEmployeeButton);

Entity/InterfaceGui/ManageEmployeeGUI.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,4 @@ public ManageEmployeeGUI() {
4141
public static void main(String[] args) {
4242
new ManageEmployeeGUI();
4343
}
44-
}
44+
}

Entity/InterfaceGui/PaymentGUI.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import java.util.Map;
77
import javax.swing.*;
88

9-
public class PaymentGUI {
9+
public class PaymentGUI extends JFrame {
1010

1111
private JFrame frame;
1212
private JPanel panel;

Entity/InterfaceGui/ProductDeleteGUI.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import java.awt.event.*;
77
import java.sql.*;
88

9-
public class ProductDeleteGUI {
9+
public class ProductDeleteGUI extends JFrame {
1010

1111
private JFrame frame;
1212
private JComboBox<String> productListComboBox;

Entity/InterfaceGui/ProductEditGUI.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import java.sql.*;
77
import javax.swing.*;
88

9-
public class ProductEditGUI {
9+
public class ProductEditGUI extends JFrame{
1010

1111
private JFrame frame;
1212
private JTextField nameField, priceField, qtyField, sizeField, colorField, materialBrandField;

Entity/InterfaceGui/ProductInputGUI.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import java.sql.*;
88
import javax.swing.*;
99

10-
public class ProductInputGUI {
10+
public class ProductInputGUI extends JFrame{
1111

1212
private JFrame frame;
1313
private JTextField nameField, priceField, qtyField, sizeField, colorField, materialBrandField;

Entity/InterfaceGui/ProductMain.java

+23-23
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,49 @@
11
package Entity.InterfaceGui;
22

3-
import java.awt.BorderLayout;
4-
import java.awt.Color;
5-
import java.awt.Font;
6-
import java.awt.GridLayout;
7-
8-
import javax.swing.JButton;
9-
import javax.swing.JFrame;
10-
import javax.swing.JPanel;
3+
import java.awt.*;
4+
import javax.swing.*;
115

126
public class ProductMain extends JFrame {
137
private JButton addPButton;
14-
private JButton editPButton;;
8+
private JButton editPButton;
159
private JButton deletePButton;
1610

17-
ProductMain() {
11+
public ProductMain() {
1812
setTitle("Manage Product");
1913
setSize(500, 300);
20-
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
14+
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
2115
setLocationRelativeTo(null);
16+
setLayout(new BorderLayout());
2217

23-
JPanel panel = new JPanel(new BorderLayout());
2418
JPanel centerPanel = new JPanel(new GridLayout(3, 1, 10, 10));
2519
centerPanel.setBackground(new Color(240, 240, 240));
2620

2721
addPButton = new JButton("Add Product");
2822
addPButton.setFont(new Font("Arial", Font.PLAIN, 14));
29-
addPButton.addActionListener(e -> {
30-
new ProductInputGUI(); // Open Manage Product GUI
31-
dispose();
32-
});
23+
addPButton.addActionListener(e -> openWindow(new ProductInputGUI()));
3324

3425
editPButton = new JButton("Edit Product");
3526
editPButton.setFont(new Font("Arial", Font.PLAIN, 14));
36-
editPButton.addActionListener(e -> {
37-
// new ProductEditGUI(); // Open Manage Product GUI
38-
dispose();
39-
});
27+
editPButton.addActionListener(e -> openWindow(new ProductEditGUI()));
28+
29+
deletePButton = new JButton("Delete Product");
30+
deletePButton.setFont(new Font("Arial", Font.PLAIN, 14));
31+
deletePButton.addActionListener(e -> openWindow(new ProductDeleteGUI()));
4032

41-
panel.add(centerPanel, BorderLayout.CENTER);
42-
add(panel);
4333
centerPanel.add(addPButton);
34+
centerPanel.add(editPButton);
35+
centerPanel.add(deletePButton);
36+
37+
add(centerPanel, BorderLayout.CENTER);
4438
setVisible(true);
4539
}
40+
41+
private void openWindow(JFrame frame) {
42+
frame.setVisible(true);
43+
dispose(); // Closes the current window when a new one opens
44+
}
45+
4646
public static void main(String[] args) {
47-
new ProductMain(); // Test with "admin" or "user"
47+
SwingUtilities.invokeLater(ProductMain::new);
4848
}
4949
}

Entity/InterfaceGui/ShopManagementGUI.java

-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ public static void main(String[] args) {
1919
SwingUtilities.invokeLater(() -> new ShopManagementGUI().createAndShowGUI());
2020
}
2121

22-
2322
public void createAndShowGUI() {
2423
frame = new JFrame("Shop Management");
2524
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

0 commit comments

Comments
 (0)