mirror of
https://github.com/jneug/zeichenmaschine.git
synced 2026-04-14 06:33:34 +02:00
Laden von Dock-Icon (macos) angepasst
This commit is contained in:
@@ -2,6 +2,7 @@ package schule.ngb.zm;
|
|||||||
|
|
||||||
import schule.ngb.zm.util.Log;
|
import schule.ngb.zm.util.Log;
|
||||||
import schule.ngb.zm.util.Validator;
|
import schule.ngb.zm.util.Validator;
|
||||||
|
import schule.ngb.zm.util.io.ImageLoader;
|
||||||
|
|
||||||
import javax.imageio.ImageIO;
|
import javax.imageio.ImageIO;
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
@@ -10,6 +11,7 @@ import java.awt.event.KeyAdapter;
|
|||||||
import java.awt.event.KeyEvent;
|
import java.awt.event.KeyEvent;
|
||||||
import java.awt.event.KeyListener;
|
import java.awt.event.KeyListener;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
@@ -174,12 +176,14 @@ public class Zeichenfenster extends JFrame {
|
|||||||
// Das Icon des Fensters ändern
|
// Das Icon des Fensters ändern
|
||||||
try {
|
try {
|
||||||
if( Zeichenmaschine.MACOS ) {
|
if( Zeichenmaschine.MACOS ) {
|
||||||
URL iconUrl = Zeichenmaschine.class.getResource("icon_512.png");
|
InputStream iconStream = this.getClass().getResourceAsStream("icon_512.png");
|
||||||
if( iconUrl != null ) {
|
if( iconStream != null ) {
|
||||||
Image icon = ImageIO.read(iconUrl);
|
Image icon = ImageIO.read(iconStream);
|
||||||
// Dock Icon in macOS setzen
|
// Dock Icon in macOS setzen
|
||||||
Taskbar taskbar = Taskbar.getTaskbar();
|
Taskbar taskbar = Taskbar.getTaskbar();
|
||||||
taskbar.setIconImage(icon);
|
taskbar.setIconImage(icon);
|
||||||
|
} else {
|
||||||
|
LOG.warn("Could not load dock-icon");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
ArrayList<Image> icons = new ArrayList<>(4);
|
ArrayList<Image> icons = new ArrayList<>(4);
|
||||||
@@ -190,8 +194,12 @@ public class Zeichenfenster extends JFrame {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if( icons.isEmpty() ) {
|
||||||
|
LOG.warn("Could not load dock-icon");
|
||||||
|
} else {
|
||||||
this.setIconImages(icons);
|
this.setIconImages(icons);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} catch( IllegalArgumentException | IOException e ) {
|
} catch( IllegalArgumentException | IOException e ) {
|
||||||
LOG.warn("Could not load image icons: %s", e.getMessage());
|
LOG.warn("Could not load image icons: %s", e.getMessage());
|
||||||
} catch( SecurityException | UnsupportedOperationException macex ) {
|
} catch( SecurityException | UnsupportedOperationException macex ) {
|
||||||
|
|||||||
@@ -797,6 +797,7 @@ public class Zeichenmaschine extends Constants {
|
|||||||
BufferedImage img = ImageLoader.createImage(canvas.getWidth(), canvas.getHeight());
|
BufferedImage img = ImageLoader.createImage(canvas.getWidth(), canvas.getHeight());
|
||||||
|
|
||||||
Graphics2D g = img.createGraphics();
|
Graphics2D g = img.createGraphics();
|
||||||
|
// TODO: Transparente Hintergründe beim Speichern von png erlauben
|
||||||
g.setColor(DEFAULT_BACKGROUND.getJavaColor());
|
g.setColor(DEFAULT_BACKGROUND.getJavaColor());
|
||||||
g.fillRect(0, 0, img.getWidth(), img.getHeight());
|
g.fillRect(0, 0, img.getWidth(), img.getHeight());
|
||||||
canvas.draw(g);
|
canvas.draw(g);
|
||||||
|
|||||||
Reference in New Issue
Block a user