[prev in list] [next in list] [prev in thread] [next in thread]
List: openjdk-2d-dev
Subject: Re: RFR: 8276849: Refresh the window icon on graphics configuration changes [v5]
From: Emmanuel Bourg <duke () openjdk ! java ! net>
Date: 2022-02-25 12:39:50
Message-ID: 8ubPWqU0vTLZW-eX7r2v9GAvrlp_4-mRKwuz8jwPHlM=.ee58d4d6-1ad0-409a-98cb-2d839e8187d6 () github ! com
[Download RAW message or body]
> When a list of icons is set on a window, the most appropiate icon is selected \
> depending on the graphics configuration. But if the graphics configuration changes \
> (because the window is moved to a different screen, or because the DPI settings of \
> the screen is changed), the frame icon isn't updated.
> Here is an example illustrating the issue:
>
> public static void main(String[] args) throws Exception {
> SwingUtilities.invokeLater(() -> {
> JFrame frame = new JFrame("Window Icon Test");
> frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
> frame.setSize(400, 300);
> frame.setVisible(true);
>
> List<Image> images = new ArrayList<>();
> for (int size = 16; size <= 32; size++) {
> // create an image displaying the size used
> BufferedImage image = new BufferedImage(size, size, BufferedImage.TYPE_INT_ARGB);
> Graphics2D g = image.createGraphics();
> g.setFont(new Font("dialog", Font.BOLD, 12));
> g.setColor(Color.BLACK);
> g.drawString(String.valueOf(size), 0, size - (size - g.getFont().getSize()) / 2);
> images.add(image);
> }
>
> frame.setIconImages(images);
> });
> }
>
> On Windows if the screen scaling is set to 100% the 16x16 icon is picked from the \
> list. If the scaling of the screen is set to 150% while the application is running, \
> the 16x16 icon is upscaled and looks blurry.
> A way to work around this issue is to listen for graphics configuration changes \
> with:
> frame.addPropertyChangeListener("graphicsConfiguration", event -> \
> frame.setIconImages(frame.getIconImages()));
>
> Ideally this should be done automatically by the JDK. Maybe the `WindowPeer` could \
> call `updateIconImages()` when `updateGraphicsData()` or `displayChanged()` is \
> invoked?
Emmanuel Bourg has updated the pull request incrementally with one additional commit \
since the last revision:
Don't refresh the frame icon on graphics configuration changes on macOS (not \
applicable)
-------------
Changes:
- all: https://git.openjdk.java.net/jdk/pull/6180/files
- new: https://git.openjdk.java.net/jdk/pull/6180/files/69987031..970ea9b6
Webrevs:
- full: https://webrevs.openjdk.java.net/?repo=jdk&pr=6180&range=04
- incr: https://webrevs.openjdk.java.net/?repo=jdk&pr=6180&range=03-04
Stats: 1 line in 1 file changed: 0 ins; 1 del; 0 mod
Patch: https://git.openjdk.java.net/jdk/pull/6180.diff
Fetch: git fetch https://git.openjdk.java.net/jdk pull/6180/head:pull/6180
PR: https://git.openjdk.java.net/jdk/pull/6180
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic