Skip to content

Commit

Permalink
ELP: GUI: Fix ImageIcon loading logic
Browse files Browse the repository at this point in the history
Signed-off-by: Zinadin Zidan <zidan44@pixelexperience.org>
Change-Id: I8867b40d18346b7848e94347fa445bea41c06f18
  • Loading branch information
ZIDAN44 committed May 18, 2023
1 parent a5ae185 commit 7318354
Show file tree
Hide file tree
Showing 16 changed files with 47 additions and 47 deletions.
8 changes: 4 additions & 4 deletions GUI/AdminGUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ public AdminGUI(Admin admin) {

this.currentAdmin = admin;

ImageIcon icon = new ImageIcon(getClass().getResource("Pictures/Common/Icon.png"));
ImageIcon icon = new ImageIcon(getClass().getResource("/GUI/Pictures/Common/Icon.png"));
setIconImage(icon.getImage());

initButtons();
initButtonColors();
setCursorIcon();

ImageIcon bgImage = new ImageIcon(getClass().getResource("Pictures/AdminGUI/A_Background.png"));
ImageIcon bgImage = new ImageIcon(getClass().getResource("/GUI/Pictures/AdminGUI/A_Background.png"));
JLabel bgLabel = new JLabel(bgImage);
bgLabel.setBounds(0, 0, getWidth(), getHeight());
add(bgLabel);
Expand All @@ -44,7 +44,7 @@ private void initButtons() {
int buttonHeight = 50;

myProfileButton = createButton("");
ImageIcon myProfileIcon = new ImageIcon("GUI/Pictures/Common/My_Profile.png");
ImageIcon myProfileIcon = new ImageIcon(getClass().getResource("/GUI/Pictures/Common/My_Profile.png"));
myProfileButton.setIcon(myProfileIcon);
myProfileButton.setBounds(90, 70, 150, 150);

Expand All @@ -58,7 +58,7 @@ private void initButtons() {
courseDataButton.setBounds(420, 410, buttonWidth, buttonHeight);

logoutButton = createButton("");
ImageIcon logoutIcon = new ImageIcon("GUI/Pictures/Common/exit.png");
ImageIcon logoutIcon = new ImageIcon(getClass().getResource("/GUI/Pictures/Common/Exit.png"));
logoutButton.setIcon(logoutIcon);
logoutButton.setBounds(1010, 15, 50, 50);
}
Expand Down
8 changes: 4 additions & 4 deletions GUI/Common/CustomCursor.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
public class CustomCursor {

public static void setCustomCursor(JFrame frame) {
ImageIcon cursorImage = new ImageIcon(CustomCursor.class.getResource("../Pictures/Common/Cursor.png"));
ImageIcon cursorImage = new ImageIcon(CustomCursor.class.getResource("/GUI/Pictures/Common/Cursor.png"));
Toolkit toolkit = Toolkit.getDefaultToolkit();
Image cursor = cursorImage.getImage();
Point hotspot = new Point(0, 0);
Expand All @@ -15,7 +15,7 @@ public static void setCustomCursor(JFrame frame) {
}

public static void setCustomCursor(JDialog dialog) {
ImageIcon cursorImage = new ImageIcon(CustomCursor.class.getResource("../Pictures/Common/Cursor.png"));
ImageIcon cursorImage = new ImageIcon(CustomCursor.class.getResource("/GUI/Pictures/Common/Cursor.png"));
Toolkit toolkit = Toolkit.getDefaultToolkit();
Image cursor = cursorImage.getImage();
Point hotspot = new Point(0, 0);
Expand All @@ -24,7 +24,7 @@ public static void setCustomCursor(JDialog dialog) {
}

public static void setHandCursor(JButton button) {
ImageIcon handCursorImage = new ImageIcon(CustomCursor.class.getResource("../Pictures/Common/HandCursor.png"));
ImageIcon handCursorImage = new ImageIcon(CustomCursor.class.getResource("/GUI/Pictures/Common/HandCursor.png"));
Toolkit toolkit = Toolkit.getDefaultToolkit();
Image cursor = handCursorImage.getImage();
Point hotspot = new Point(0, 0);
Expand All @@ -33,7 +33,7 @@ public static void setHandCursor(JButton button) {
}

public static void setHandCursor(JTextField field) {
ImageIcon handCursorImage = new ImageIcon(CustomCursor.class.getResource("../Pictures/Common/HandCursor.png"));
ImageIcon handCursorImage = new ImageIcon(CustomCursor.class.getResource("/GUI/Pictures/Common/HandCursor.png"));
Toolkit toolkit = Toolkit.getDefaultToolkit();
Image cursor = handCursorImage.getImage();
Point hotspot = new Point(0, 0);
Expand Down
4 changes: 2 additions & 2 deletions GUI/DataGUI/CourseData.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ public CourseData(AdminGUI adminGUI) {
CourseList.loadCourseListFromFile();

// Load the image for the icon
ImageIcon icon = new ImageIcon(getClass().getResource("../Pictures/Common/Icon.png"));
ImageIcon icon = new ImageIcon(getClass().getResource("/GUI/Pictures/Common/Icon.png"));
setIconImage(icon.getImage());

initButtons();
initButtonColors();
setCursorIcon();

// Add background image
ImageIcon bgImage = new ImageIcon(getClass().getResource("../Pictures/AdminGUI/Data_Background.png"));
ImageIcon bgImage = new ImageIcon(getClass().getResource("/GUI/Pictures/AdminGUI/Data_Background.png"));
JLabel bgLabel = new JLabel(bgImage);
bgLabel.setBounds(0, 0, getWidth(), getHeight());
add(bgLabel);
Expand Down
4 changes: 2 additions & 2 deletions GUI/DataGUI/StudentData.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ public StudentData(AdminGUI adminGUI) {
StudentList.loadStudentListFromFile();

// Load the image for the icon
ImageIcon icon = new ImageIcon(getClass().getResource("../Pictures/Common/Icon.png"));
ImageIcon icon = new ImageIcon(getClass().getResource("/GUI/Pictures/Common/Icon.png"));
setIconImage(icon.getImage());

initButtons();
initButtonColors();
setCursorIcon();

// Add background image
ImageIcon bgImage = new ImageIcon(getClass().getResource("../Pictures/AdminGUI/Data_Background.png"));
ImageIcon bgImage = new ImageIcon(getClass().getResource("/GUI/Pictures/AdminGUI/Data_Background.png"));
JLabel bgLabel = new JLabel(bgImage);
bgLabel.setBounds(0, 0, getWidth(), getHeight());
add(bgLabel);
Expand Down
4 changes: 2 additions & 2 deletions GUI/DataGUI/TeacherData.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ public TeacherData(AdminGUI adminGUI) {
TeacherList.loadTeacherListFromFile();

// Load the image for the icon
ImageIcon icon = new ImageIcon(getClass().getResource("../Pictures/Common/Icon.png"));
ImageIcon icon = new ImageIcon(getClass().getResource("/GUI/Pictures/Common/Icon.png"));
setIconImage(icon.getImage());

initButtons();
initButtonColors();
setCursorIcon();

// Add background image
ImageIcon bgImage = new ImageIcon(getClass().getResource("../Pictures/AdminGUI/Data_Background.png"));
ImageIcon bgImage = new ImageIcon(getClass().getResource("/GUI/Pictures/AdminGUI/Data_Background.png"));
JLabel bgLabel = new JLabel(bgImage);
bgLabel.setBounds(0, 0, getWidth(), getHeight());
add(bgLabel);
Expand Down
2 changes: 1 addition & 1 deletion GUI/Dialog/AdminDialog/Admin/EditProfileDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ private void createLayout() {
passwordField.setFont(fieldFont);
add(passwordField);

ImageIcon eyeIcon = new ImageIcon("GUI/Pictures/Common/eye.png");
ImageIcon eyeIcon = new ImageIcon(getClass().getResource("/GUI/Pictures/Common/eye.png"));
showPasswordButton = new JButton(eyeIcon);
showPasswordButton.addActionListener(this);
showPasswordButton.setBounds(355, 132, 25, 25);
Expand Down
2 changes: 1 addition & 1 deletion GUI/Dialog/StudentDialog/EditProfileDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ private void createLayout() {
passwordField.setFont(fieldFont);
add(passwordField);

ImageIcon eyeIcon = new ImageIcon("GUI/Pictures/Common/eye.png");
ImageIcon eyeIcon = new ImageIcon(getClass().getResource("/GUI/Pictures/Common/eye.png"));
showPasswordButton = new JButton(eyeIcon);
showPasswordButton.addActionListener(this);
showPasswordButton.setBounds(355, 172, 25, 25);
Expand Down
2 changes: 1 addition & 1 deletion GUI/Dialog/TeacherDialog/EditProfileDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ private void createLayout() {
passwordField.setFont(fieldFont);
add(passwordField);

ImageIcon eyeIcon = new ImageIcon("GUI/Pictures/Common/eye.png");
ImageIcon eyeIcon = new ImageIcon(getClass().getResource("/GUI/Pictures/Common/eye.png"));
showPasswordButton = new JButton(eyeIcon);
showPasswordButton.addActionListener(this);
showPasswordButton.setBounds(355, 172, 25, 25);
Expand Down
4 changes: 2 additions & 2 deletions GUI/HomePage.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public HomePage() {
setLayout(null);
setResizable(false);

ImageIcon icon = new ImageIcon(getClass().getResource("Pictures/Common/Icon.png"));
ImageIcon icon = new ImageIcon(getClass().getResource("/GUI/Pictures/Common/Icon.png"));
setIconImage(icon.getImage());

JLabel titleLabel = new JLabel("Welcome to E-Learning Platform!");
Expand Down Expand Up @@ -56,7 +56,7 @@ public HomePage() {
add(teacherButton);
add(studentButton);

ImageIcon bgImage = new ImageIcon(getClass().getResource("Pictures/Home/BG.png"));
ImageIcon bgImage = new ImageIcon(getClass().getResource("/GUI/Pictures/Home/BG.png"));
JLabel bgLabel = new JLabel(bgImage);
bgLabel.setBounds(0, 0, getWidth(), getHeight());
add(bgLabel);
Expand Down
10 changes: 5 additions & 5 deletions GUI/Login/AdminLogin.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ public AdminLogin() {
setSize(1100, 800);
setLocationRelativeTo(null);

ImageIcon icon = new ImageIcon(getClass().getResource("../Pictures/Common/Icon.png"));
ImageIcon icon = new ImageIcon(getClass().getResource("/GUI/Pictures/Common/Icon.png"));
setIconImage(icon.getImage());

ImageIcon backgroundIcon = new ImageIcon("GUI/Pictures/AdminLogin/background.png");
ImageIcon backgroundIcon = new ImageIcon(getClass().getResource("/GUI/Pictures/AdminLogin/background.png"));
Image backgroundImage = backgroundIcon.getImage().getScaledInstance(getWidth(), getHeight(),
Image.SCALE_SMOOTH);
backgroundIcon = new ImageIcon(backgroundImage);
Expand Down Expand Up @@ -54,21 +54,21 @@ public AdminLogin() {
passwordField.setPreferredSize(new Dimension(150, 30));
passwordField.setBounds(470, 360, 170, 30);

ImageIcon loginIcon = new ImageIcon("GUI/Pictures/Common/login.png");
ImageIcon loginIcon = new ImageIcon(getClass().getResource("/GUI/Pictures/Common/login.png"));
loginButton = new JButton(loginIcon);
loginButton.addActionListener(this);
loginButton.setPreferredSize(new Dimension(50, 30));
loginButton.setBounds(515, 407, 70, 30);

ImageIcon exitIcon = new ImageIcon("GUI/Pictures/Common/Exit.png");
ImageIcon exitIcon = new ImageIcon(getClass().getResource("/GUI/Pictures/Common/Exit.png"));
exitButton = new JButton(exitIcon);
exitButton.addActionListener(this);
exitButton.setPreferredSize(new Dimension(25, 25));
exitButton.setBounds(1015, 30, 45, 45);
exitButton.setBackground(Color.decode("#A8251A"));
backgroundLabel.add(exitButton);

ImageIcon eyeIcon = new ImageIcon("GUI/Pictures/Common/eye.png");
ImageIcon eyeIcon = new ImageIcon(getClass().getResource("/GUI/Pictures/Common/eye.png"));
showPasswordButton = new JButton(eyeIcon);
showPasswordButton.addActionListener(this);
showPasswordButton.setBounds(650, 362, 25, 25);
Expand Down
12 changes: 6 additions & 6 deletions GUI/Login/StudentLogin.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ public StudentLogin() {
setSize(1100, 800);
setLocationRelativeTo(null);

ImageIcon icon = new ImageIcon(getClass().getResource("../Pictures/Common/Icon.png"));
ImageIcon icon = new ImageIcon(getClass().getResource("/GUI/Pictures/Common/Icon.png"));
setIconImage(icon.getImage());

ImageIcon backgroundIcon = new ImageIcon("GUI/Pictures/StudentLogin/background.png");
ImageIcon backgroundIcon = new ImageIcon(getClass().getResource("/GUI/Pictures/StudentLogin/Background.png"));
Image backgroundImage = backgroundIcon.getImage().getScaledInstance(getWidth(), getHeight(),
Image.SCALE_SMOOTH);
backgroundIcon = new ImageIcon(backgroundImage);
Expand Down Expand Up @@ -57,29 +57,29 @@ public StudentLogin() {
passwordField.setPreferredSize(new Dimension(150, 30));
passwordField.setBounds(470, 360, 170, 30);

ImageIcon signUpIcon = new ImageIcon("GUI/Pictures/StudentLogin/Signup.png");
ImageIcon signUpIcon = new ImageIcon(getClass().getResource("/GUI/Pictures/StudentLogin/Signup.png"));
Image scaledImage = signUpIcon.getImage().getScaledInstance(235, 200, Image.SCALE_SMOOTH);
ImageIcon scaledIcon = new ImageIcon(scaledImage);
signUpButton = new RoundedCornerButton("", 45);
signUpButton.setIcon(scaledIcon);
signUpButton.addActionListener(this);
signUpButton.setBounds(435, 450, 230, 35);

ImageIcon loginIcon = new ImageIcon("GUI/Pictures/Common/login.png");
ImageIcon loginIcon = new ImageIcon(getClass().getResource("/GUI/Pictures/Common/login.png"));
loginButton = new JButton(loginIcon);
loginButton.addActionListener(this);
loginButton.setPreferredSize(new Dimension(50, 30));
loginButton.setBounds(515, 407, 70, 30);

ImageIcon exitIcon = new ImageIcon("GUI/Pictures/Common/Exit.png");
ImageIcon exitIcon = new ImageIcon(getClass().getResource("/GUI/Pictures/Common/Exit.png"));
exitButton = new JButton(exitIcon);
exitButton.addActionListener(this);
exitButton.setPreferredSize(new Dimension(25, 25));
exitButton.setBounds(1015, 30, 45, 45);
exitButton.setBackground(Color.decode("#A8251A"));
backgroundLabel.add(exitButton);

ImageIcon eyeIcon = new ImageIcon("GUI/Pictures/Common/eye.png");
ImageIcon eyeIcon = new ImageIcon(getClass().getResource("/GUI/Pictures/Common/eye.png"));
showPasswordButton = new JButton(eyeIcon);
showPasswordButton.addActionListener(this);
showPasswordButton.setBounds(650, 362, 25, 25);
Expand Down
10 changes: 5 additions & 5 deletions GUI/Login/TeacherLogin.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ public TeacherLogin() {
setSize(1100, 800);
setLocationRelativeTo(null);

ImageIcon icon = new ImageIcon(getClass().getResource("../Pictures/Common/Icon.png"));
ImageIcon icon = new ImageIcon(getClass().getResource("/GUI/Pictures/Common/Icon.png"));
setIconImage(icon.getImage());

ImageIcon backgroundIcon = new ImageIcon("GUI/Pictures/TeacherLogin/background.png");
ImageIcon backgroundIcon = new ImageIcon(getClass().getResource("/GUI/Pictures/TeacherLogin/background.png"));
Image backgroundImage = backgroundIcon.getImage().getScaledInstance(getWidth(), getHeight(),
Image.SCALE_SMOOTH);
backgroundIcon = new ImageIcon(backgroundImage);
Expand Down Expand Up @@ -54,21 +54,21 @@ public TeacherLogin() {
passwordField.setPreferredSize(new Dimension(150, 30));
passwordField.setBounds(470, 360, 170, 30);

ImageIcon loginIcon = new ImageIcon("GUI/Pictures/Common/login.png");
ImageIcon loginIcon = new ImageIcon(getClass().getResource("/GUI/Pictures/Common/login.png"));
loginButton = new JButton(loginIcon);
loginButton.addActionListener(this);
loginButton.setPreferredSize(new Dimension(50, 30));
loginButton.setBounds(515, 407, 70, 30);

ImageIcon exitIcon = new ImageIcon("GUI/Pictures/Common/Exit.png");
ImageIcon exitIcon = new ImageIcon(getClass().getResource("/GUI/Pictures/Common/Exit.png"));
exitButton = new JButton(exitIcon);
exitButton.addActionListener(this);
exitButton.setPreferredSize(new Dimension(25, 25));
exitButton.setBounds(1015, 30, 45, 45);
exitButton.setBackground(Color.decode("#A8251A"));
backgroundLabel.add(exitButton);

ImageIcon eyeIcon = new ImageIcon("GUI/Pictures/Common/eye.png");
ImageIcon eyeIcon = new ImageIcon(getClass().getResource("/GUI/Pictures/Common/eye.png"));
showPasswordButton = new JButton(eyeIcon);
showPasswordButton.addActionListener(this);
showPasswordButton.setBounds(650, 362, 25, 25);
Expand Down
4 changes: 2 additions & 2 deletions GUI/Payment/PaymentGUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ public PaymentGUI(Frame parent, Student student) {
setLocationRelativeTo(null);
setLayout(null);

ImageIcon icon = new ImageIcon(getClass().getResource("../Pictures/Common/PaymentIcon.png"));
ImageIcon icon = new ImageIcon(getClass().getResource("/GUI/Pictures/Common/PaymentIcon.png"));
setIconImage(icon.getImage());

ImageIcon backgroundIcon = new ImageIcon("GUI/Pictures/Common/PaymentBG.png");
ImageIcon backgroundIcon = new ImageIcon(getClass().getResource("/GUI/Pictures/Common/PaymentBG.png"));
Image backgroundImage = backgroundIcon.getImage().getScaledInstance(getWidth(), getHeight(),
Image.SCALE_SMOOTH);
backgroundIcon = new ImageIcon(backgroundImage);
Expand Down
4 changes: 2 additions & 2 deletions GUI/SignUP/StudentSignUp.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ public StudentSignUp() {
// Load data
StudentList.loadStudentListFromFile();

ImageIcon icon = new ImageIcon(getClass().getResource("../Pictures/Common/Icon.png"));
ImageIcon icon = new ImageIcon(getClass().getResource("/GUI/Pictures/Common/Icon.png"));
setIconImage(icon.getImage());

ImageIcon backgroundIcon = new ImageIcon("GUI/Pictures/StudentSingUP/background.png");
ImageIcon backgroundIcon = new ImageIcon(getClass().getResource("/GUI/Pictures/StudentSingUP/Background.png"));
Image backgroundImage = backgroundIcon.getImage().getScaledInstance(getWidth(), getHeight(),
Image.SCALE_SMOOTH);
backgroundIcon = new ImageIcon(backgroundImage);
Expand Down
8 changes: 4 additions & 4 deletions GUI/StudentGUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@ public StudentGUI(Student student) {
CourseList.loadCourseListFromFile();
TeacherList.loadTeacherListFromFile();

ImageIcon icon = new ImageIcon(getClass().getResource("Pictures/Common/Icon.png"));
ImageIcon icon = new ImageIcon(getClass().getResource("/GUI/Pictures/Common/Icon.png"));
setIconImage(icon.getImage());

initButtons();
initButtonColors();
setCursorIcon();

ImageIcon bgImage = new ImageIcon(getClass().getResource("Pictures/StudentGUI/Background.png"));
ImageIcon bgImage = new ImageIcon(getClass().getResource("/GUI/Pictures/StudentGUI/Background.png"));
JLabel bgLabel = new JLabel(bgImage);
bgLabel.setBounds(0, 0, getWidth(), getHeight());
add(bgLabel);
Expand All @@ -48,7 +48,7 @@ private void initButtons() {
int buttonHeight = 50;

myProfileButton = createButton("");
ImageIcon myProfileIcon = new ImageIcon("GUI/Pictures/StudentGUI/My_Profile.png");
ImageIcon myProfileIcon = new ImageIcon(getClass().getResource("/GUI/Pictures/StudentGUI/My_Profile.png"));
myProfileButton.setIcon(myProfileIcon);
myProfileButton.setBounds(90, 70, 150, 150);

Expand All @@ -60,7 +60,7 @@ private void initButtons() {
showMediaFilesButton.setBounds(410, 400, buttonWidth, buttonHeight);

logoutButton = createButton("");
ImageIcon logoutIcon = new ImageIcon(getClass().getResource("Pictures/Common/exit.png"));
ImageIcon logoutIcon = new ImageIcon(getClass().getResource("/GUI/Pictures/Common/Exit.png"));
logoutButton.setIcon(logoutIcon);
logoutButton.setBounds(1010, 15, 50, 50);
}
Expand Down
8 changes: 4 additions & 4 deletions GUI/TeacherGUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@ public TeacherGUI(Teacher teacher) {

this.currentTeacher = teacher;

ImageIcon icon = new ImageIcon(getClass().getResource("Pictures/Common/Icon.png"));
ImageIcon icon = new ImageIcon(getClass().getResource("/GUI/Pictures/Common/Icon.png"));
setIconImage(icon.getImage());

initButtons();
initButtonColors();
setCursorIcon();

ImageIcon bgImage = new ImageIcon(getClass().getResource("Pictures/TeacherGUI/Background.png"));
ImageIcon bgImage = new ImageIcon(getClass().getResource("/GUI/Pictures/TeacherGUI/Background.png"));
JLabel bgLabel = new JLabel(bgImage);
bgLabel.setBounds(0, 0, getWidth(), getHeight());
add(bgLabel);
Expand All @@ -45,7 +45,7 @@ private void initButtons() {
int buttonHeight = 50;

myProfileButton = createButton("");
ImageIcon myProfileIcon = new ImageIcon("GUI/Pictures/TeacherGUI/My_Profile.png");
ImageIcon myProfileIcon = new ImageIcon(getClass().getResource("/GUI/Pictures/TeacherGUI/My_Profile.png"));
myProfileButton.setIcon(myProfileIcon);
myProfileButton.setBounds(90, 70, 150, 150);

Expand All @@ -61,7 +61,7 @@ private void initButtons() {
showSelectedCoursesButton.setBounds(410, 460, buttonWidth, buttonHeight);

logoutButton = createButton("");
ImageIcon logoutIcon = new ImageIcon("GUI/Pictures/Common/exit.png");
ImageIcon logoutIcon = new ImageIcon(getClass().getResource("/GUI/Pictures/Common/exit.png"));
logoutButton.setIcon(logoutIcon);
logoutButton.setBounds(1010, 15, 50, 50);
}
Expand Down

0 comments on commit 7318354

Please sign in to comment.