Hey!
Ich will folgendes Icon laden: https://www.microsoft.com/favicon.ico
Problem: Icon ist null
Hoffe mir kann wer helfen
Ich will folgendes Icon laden: https://www.microsoft.com/favicon.ico
Problem: Icon ist null
Java:
public void loadIcon() {
if (iconMode.equals("file")) {
try {
icon = ImageIO.read(new File(iconSrc));
} catch (IOException e) {
}
} else if (iconMode.equals("web")) {
try {
List<BufferedImage> images;
String path = iconSrc + "favicon.ico/"; // iconSrc = https://www.microsoft.com/
InputStream istr = new URL(path).openStream();
images = ICODecoder.read(istr);
icon = images.get(0);
} catch (Exception e) {
try {
List<BufferedImage> images;
String path = iconSrc + "favicon.ico";
InputStream istr = new URL(path).openStream();
images = ICODecoder.read(istr);
icon = images.get(0);
} catch (Exception e1) {
}
}
}
if (!iconMode.equals("none")) {
iconContainer = new JLabel(new ImageIcon(getScaledImage(icon, 80, 80)));
iconContainer.setPreferredSize(new Dimension(120, 120));
iconContainer.setMaximumSize(iconContainer.getPreferredSize());
iconContainer.setBackground(Color.white);
this.add(iconContainer, BorderLayout.WEST);
}
}
Hoffe mir kann wer helfen