From 9d1f90fdf42f8b49188e712571795edb42d4c076 Mon Sep 17 00:00:00 2001 From: jhdcruz Date: Wed, 14 Dec 2022 16:56:50 +0800 Subject: [PATCH] use `EventQueue` instead --- .github/workflows/ci.yml | 3 --- src/main/java/com/pharmacy/views/Dashboard.java | 7 ++++--- src/main/java/com/pharmacy/views/LoginPage.java | 7 +++---- 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 669d21e..bfa23ac 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -29,9 +29,6 @@ jobs: key: ${{ runner.os }}-sonar restore-keys: ${{ runner.os }}-sonar - - name: Test - run: mvn test - - name: Build and analyze env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/src/main/java/com/pharmacy/views/Dashboard.java b/src/main/java/com/pharmacy/views/Dashboard.java index 4729aff..62daa33 100644 --- a/src/main/java/com/pharmacy/views/Dashboard.java +++ b/src/main/java/com/pharmacy/views/Dashboard.java @@ -2,13 +2,13 @@ import com.pharmacy.controllers.UserController; import com.pharmacy.models.UserModel; - -import javax.swing.JOptionPane; import java.awt.CardLayout; import java.awt.Dimension; +import java.awt.EventQueue; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; import java.time.LocalDateTime; +import javax.swing.JOptionPane; public class Dashboard extends javax.swing.JFrame { @@ -36,7 +36,8 @@ public Dashboard(String username, String userType, UserModel userModel) { notForEmployee(); } - id = new UserController(id).getUserId(username); + // TODO: Inherit `id` from login instead + EventQueue.invokeLater(() -> id = new UserController(id).getUserId(username)); // Panel Layout set to Card Layout to allow switching between different sections displayPanel.setLayout(layout); diff --git a/src/main/java/com/pharmacy/views/LoginPage.java b/src/main/java/com/pharmacy/views/LoginPage.java index a712bc9..321c6d1 100644 --- a/src/main/java/com/pharmacy/views/LoginPage.java +++ b/src/main/java/com/pharmacy/views/LoginPage.java @@ -2,10 +2,9 @@ import com.pharmacy.database.DatabaseInstance; import com.pharmacy.models.UserModel; - -import javax.swing.JOptionPane; -import javax.swing.SwingUtilities; +import java.awt.EventQueue; import java.time.LocalDateTime; +import javax.swing.JOptionPane; public class LoginPage extends javax.swing.JFrame { @@ -161,7 +160,7 @@ private void loginButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-F dispose(); - SwingUtilities.invokeLater(() -> new Dashboard(username, userType, userModel)); + EventQueue.invokeLater(() -> new Dashboard(username, userType, userModel)); } else { JOptionPane.showMessageDialog( null,