I was thinking the other day how could I get the icon from a website and make it show and update when it is updated on the site so I made this code:
URL url2 = null;
boolean updateIcon = true;
try {
url2 = new URL("https://dl.dropboxusercontent.com/s/70rhm66myw8ay2v/Perception%20Logo.png");
} catch (MalformedURLException ex) {
updateIcon = false;
ex.printStackTrace();
}
if (updateIcon) {
System.out.println("[Perception] Icon updated.");
if (ComputerCheck.isWindows()) {
Image bimg = Toolkit.getDefaultToolkit().getImage(url2);
this.setIconImage(bimg);
} else if (ComputerCheck.isMac()) {
Application application = Application.getApplication();
Image image = Toolkit.getDefaultToolkit().getImage(url2);
application.setDockIconImage(image);
}
}
And it works 100% fine but it makes the startup time a lot slower. I was wondering how could I optimize this.