I'm currently trying to create a method to change all of my jFrames' icons from a single, separate class (in a different package) at once, so that I don't need to add the icon change method to EVERY jFrame class, and instead just having to copy one or two lines of code and change the target jFrame.
But I can't seem to actually make it work, regardless of the way I try. Here's the code for the class that is supposed to change the icon:
package com.sts.images;
import com.sts.screens.LoginScreen;
import javax.swing.ImageIcon;
public class ChangeIcon{
LoginScreen LS = new LoginScreen();
ImageIcon IC = new ImageIcon("images/icon.png");
LoginScreen.setIconImage(IC.getImage()); //First thing I tried...
LS.setIconImage(IC.getImage()); //Second thing I tried....
}
(NOTE: The "LoginScreen" jFrame is located in another package within the same project.)
Is it possible at all to do such a thing? Or should I just add it to every jFrame instead?