Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #37958 > unrolled thread
| Started by | Eric Douglas <e.d.programmer@gmail.com> |
|---|---|
| First post | 2018-01-19 05:28 -0800 |
| Last post | 2018-01-22 14:18 -0800 |
| Articles | 14 — 5 participants |
Back to article view | Back to comp.lang.java.programmer
How do you scale a JCheckBox? Eric Douglas <e.d.programmer@gmail.com> - 2018-01-19 05:28 -0800
Re: How do you scale a JCheckBox? Eric Douglas <e.d.programmer@gmail.com> - 2018-01-19 13:13 -0800
Re: How do you scale a JCheckBox? Daniele Futtorovic <da.futt.news@laposte.net> - 2018-01-20 09:49 +0100
Re: How do you scale a JCheckBox? Eric Douglas <e.d.programmer@gmail.com> - 2018-01-22 04:56 -0800
Re: How do you scale a JCheckBox? Eric Douglas <e.d.programmer@gmail.com> - 2018-01-22 08:54 -0800
Re: How do you scale a JCheckBox? Knute Johnson <nospam@rabbitbrush.frazmtn.com> - 2018-01-21 14:05 -0600
Re: How do you scale a JCheckBox? Eric Douglas <e.d.programmer@gmail.com> - 2018-01-22 07:25 -0800
Re: How do you scale a JCheckBox? Knute Johnson <nospam@rabbitbrush.frazmtn.com> - 2018-01-22 11:38 -0600
Re: How do you scale a JCheckBox? Eric Douglas <e.d.programmer@gmail.com> - 2018-01-22 10:17 -0800
Re: How do you scale a JCheckBox? Eric Douglas <e.d.programmer@gmail.com> - 2018-01-22 12:49 -0800
Re: How do you scale a JCheckBox? Knute Johnson <nospam@rabbitbrush.frazmtn.com> - 2018-01-22 15:31 -0600
Re: How do you scale a JCheckBox? j4n bur53 <janburse@fastmail.fm> - 2018-01-22 22:37 +0100
Re: How do you scale a JCheckBox? bursejan@gmail.com - 2018-01-22 14:16 -0800
Re: How do you scale a JCheckBox? bursejan@gmail.com - 2018-01-22 14:18 -0800
| From | Eric Douglas <e.d.programmer@gmail.com> |
|---|---|
| Date | 2018-01-19 05:28 -0800 |
| Subject | How do you scale a JCheckBox? |
| Message-ID | <316fc0bc-d954-41c1-b913-3dd6e52e902a@googlegroups.com> |
I've tried searching and found others had the same problem but no clear solution. I tried digging into the code that draws it but it doesn't look good. I resize a window ie pull up a window on a Surface Pro and set view to 300% and all JComponents change size, except for the box portion of the JCheckBoxes. This guy had the same problem https://arstechnica.com/civis/viewtopic.php?f=20&t=123408 This guy made a hack solution to generate a custom icon instead of using the ones Oracle provided. https://stackoverflow.com/questions/22691353/scale-a-jcheckbox-box Here's another possible hack solution. https://stackoverflow.com/questions/4770022/make-jcheckbox-bigger Every other control is truly dynamic and simply scales when Windows tells it to, why are checkboxes (and apparently radiobuttons) so difficult?
[toc] | [next] | [standalone]
| From | Eric Douglas <e.d.programmer@gmail.com> |
|---|---|
| Date | 2018-01-19 13:13 -0800 |
| Message-ID | <985fa054-03a9-4490-a298-a0df9ac4171f@googlegroups.com> |
| In reply to | #37958 |
On Friday, January 19, 2018 at 8:29:18 AM UTC-5, Eric Douglas wrote:
> I've tried searching and found others had the same problem but no clear solution. I tried digging into the code that draws it but it doesn't look good. I resize a window ie pull up a window on a Surface Pro and set view to 300% and all JComponents change size, except for the box portion of the JCheckBoxes.
>
Any ideas? I'm trying something that almost seems to work but one of my calculations is off a bit.
I put this in my constructor.
setUI(new BasicCheckBoxUI() {
public Icon getDefaultIcon() {
Icon uiIcon = super.getDefaultIcon();
if (boxIcon == null) {
boxIcon = new CheckBoxIcon(uiIcon);
}
return boxIcon;
}
});
This refers to my inner class.
private class CheckBoxIcon implements Icon {
final Icon uiIcon;
public CheckBoxIcon(Icon wrapMe) {
uiIcon = wrapMe;
}
@Override
public void paintIcon(Component c, Graphics g, int x, int y) {
int ch = getHeight();
if (ch > 0) {
final Insets i = getInsets();
ch -= (i.top + i.bottom);
final Graphics2D g2 = (Graphics2D) g.create();
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
g2.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_ON);
g2.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC);
g2.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
g2.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_PURE);
g2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
final double ih = uiIcon.getIconHeight();
final double scale = ch / ih;
double movex = x - (x * scale);
double movey = y - (y * scale);
g2.scale(scale, scale);
g2.translate(movex, movey);
int drawx = (int) (x + movex);
int drawy = (int) (y + movey);
uiIcon.paintIcon(c, g2, drawx, drawy);
g2.dispose();
}
}
@Override
public int getIconWidth() {
return uiIcon.getIconWidth();
}
@Override
public int getIconHeight() {
return uiIcon.getIconHeight();
}
}
My boxes now look like they're drawing the correct size but a bit high and to the left. Calculations are tricky as some of these variables get negative values.
[toc] | [prev] | [next] | [standalone]
| From | Daniele Futtorovic <da.futt.news@laposte.net> |
|---|---|
| Date | 2018-01-20 09:49 +0100 |
| Message-ID | <p3uvrh$91o$1@dont-email.me> |
| In reply to | #37960 |
On 2018-01-19 22:13, Eric Douglas wrote: > On Friday, January 19, 2018 at 8:29:18 AM UTC-5, Eric Douglas wrote: >> I've tried searching and found others had the same problem but no clear solution. I tried digging into the code that draws it but it doesn't look good. I resize a window ie pull up a window on a Surface Pro and set view to 300% and all JComponents change size, except for the box portion of the JCheckBoxes. >> > > Any ideas? <snip /> Seems to me you've already found the answer to your question: the JCheckbox icon doesn't change size because, drumroll... it's an icon. I believe there should be a way for you to change the icon used by the JCheckbox component without any UI-specific code, probably via some Swing property. I'd look into that if I were you. -- DF.
[toc] | [prev] | [next] | [standalone]
| From | Eric Douglas <e.d.programmer@gmail.com> |
|---|---|
| Date | 2018-01-22 04:56 -0800 |
| Message-ID | <27c7b83e-173e-466f-b44e-cb11bccff237@googlegroups.com> |
| In reply to | #37961 |
On Saturday, January 20, 2018 at 3:50:09 AM UTC-5, Daniele Futtorovic wrote: > Seems to me you've already found the answer to your question: the > JCheckbox icon doesn't change size because, drumroll... it's an icon. > > I believe there should be a way for you to change the icon used by the > JCheckbox component without any UI-specific code, probably via some > Swing property. I'd look into that if I were you. > > -- > DF. I'm using Java 8, currently update 144. Yes I don't want to create my own custom icon, and I'd rather not create a new icon every time it draws the checkbox. I just want the default look and feel to scale the icon. I managed to do that with a custom UI, which looks ok except I keep getting the box in the wrong x,y. The w,h comes out fine but I can't figure out quite the right positioning calculation. It is also odd the paintIcon method still only accepts int, while Graphics2D accepts doubles.
[toc] | [prev] | [next] | [standalone]
| From | Eric Douglas <e.d.programmer@gmail.com> |
|---|---|
| Date | 2018-01-22 08:54 -0800 |
| Message-ID | <ae52db23-2c72-49c7-afa6-1cb81c69886d@googlegroups.com> |
| In reply to | #37960 |
On Friday, January 19, 2018 at 4:13:38 PM UTC-5, Eric Douglas wrote: > > My boxes now look like they're drawing the correct size but a bit high and to the left. Calculations are tricky as some of these variables get negative values. So it looks like my scale is accurate. I just realized my positioning is wrong because I was trying to take the x,y given to the method from the Oracle code and adjust it for the scale, but while they didn't adjust the size of the icon they did adjust the x,y attempting to center the icon on the control even though their icon may be bigger than the control. I just need to use the width and height of the control and recalculate x and y from scratch based on the scaled icon size.
[toc] | [prev] | [next] | [standalone]
| From | Knute Johnson <nospam@rabbitbrush.frazmtn.com> |
|---|---|
| Date | 2018-01-21 14:05 -0600 |
| Message-ID | <p42rpp$jku$1@dont-email.me> |
| In reply to | #37958 |
On 1/19/2018 7:28 AM, Eric Douglas wrote: > I've tried searching and found others had the same problem but no clear solution. I tried digging into the code that draws it but it doesn't look good. I resize a window ie pull up a window on a Surface Pro and set view to 300% and all JComponents change size, except for the box portion of the JCheckBoxes. > > This guy had the same problem > https://arstechnica.com/civis/viewtopic.php?f=20&t=123408 > > This guy made a hack solution to generate a custom icon instead of using the ones Oracle provided. > https://stackoverflow.com/questions/22691353/scale-a-jcheckbox-box > > Here's another possible hack solution. > https://stackoverflow.com/questions/4770022/make-jcheckbox-bigger > > Every other control is truly dynamic and simply scales when Windows tells it to, why are checkboxes (and apparently radiobuttons) so difficult? > Which runtime version are you using? I think it was with Java 8 that Swing components started scaling better. I've got 9 in this computer. Just tested a JCheckBox and changed the size on my display from 225% to 300% and the box got bigger along with the text.
[toc] | [prev] | [next] | [standalone]
| From | Eric Douglas <e.d.programmer@gmail.com> |
|---|---|
| Date | 2018-01-22 07:25 -0800 |
| Message-ID | <0981e378-abef-4acc-a9c4-b67d68a75f35@googlegroups.com> |
| In reply to | #37963 |
On Sunday, January 21, 2018 at 3:05:31 PM UTC-5, Knute Johnson wrote: > > Which runtime version are you using? I think it was with Java 8 that > Swing components started scaling better. I've got 9 in this computer. > Just tested a JCheckBox and changed the size on my display from 225% to > 300% and the box got bigger along with the text. I put in some logging for debugging. My desktop (running Windows 8.1) is set to 1920x1080. I don't see a zoom % option. It has a "make text larger or smaller" option, whatever that means is set all the way to smaller. A Surface Pro 4 (running Windows 10) default resolution is 2736x1824. With this resolution, and a 300% zoom setting, my 800x600 window looks about 1/3 the height of the screen. My desktop reports the JCheckBox height of 16 (hardcoded height with a setSize() and a null layout), and an icon (box) height of 13. The tablet reports the same JCheckBox height of 15 and an icon height of 40, so the text does auto-fit but if I don't manually scale the box it's way too big. I forget what I set the resolution to, but we do have one desktop using a 27" tv for output and the boxes have always been too big. Oddly, the default resolution for the Surface Pro 4 is a 1.5 ratio, and it's the only resolution option that is 1.5. If I can't scale all the windows and controls to fit properly on the default resolution my best workaround is to set the resolution on the tablets to 1680x1050, which is 1.6 and gets some black bars on the top and bottom. I suspect the X, minimize, and maximize buttons on JFrame are also icons since the rest of the JFrame and everything in it got small but those buttons are really big.
[toc] | [prev] | [next] | [standalone]
| From | Knute Johnson <nospam@rabbitbrush.frazmtn.com> |
|---|---|
| Date | 2018-01-22 11:38 -0600 |
| Message-ID | <p457io$r3l$1@dont-email.me> |
| In reply to | #37965 |
On 1/22/2018 09:25, Eric Douglas wrote: > On Sunday, January 21, 2018 at 3:05:31 PM UTC-5, Knute Johnson wrote: >> >> Which runtime version are you using? I think it was with Java 8 that >> Swing components started scaling better. I've got 9 in this computer. >> Just tested a JCheckBox and changed the size on my display from 225% to >> 300% and the box got bigger along with the text. > > I put in some logging for debugging. My desktop (running Windows 8.1) is set to 1920x1080. I don't see a zoom % option. It has a "make text larger or smaller" option, whatever that means is set all the way to smaller. A Surface Pro 4 (running Windows 10) default resolution is 2736x1824. With this resolution, and a 300% zoom setting, my 800x600 window looks about 1/3 the height of the screen. > > My desktop reports the JCheckBox height of 16 (hardcoded height with a setSize() and a null layout), and an icon (box) height of 13. The tablet reports the same JCheckBox height of 15 and an icon height of 40, so the text does auto-fit but if I don't manually scale the box it's way too big. > > I forget what I set the resolution to, but we do have one desktop using a 27" tv for output and the boxes have always been too big. > > Oddly, the default resolution for the Surface Pro 4 is a 1.5 ratio, and it's the only resolution option that is 1.5. If I can't scale all the windows and controls to fit properly on the default resolution my best workaround is to set the resolution on the tablets to 1680x1050, which is 1.6 and gets some black bars on the top and bottom. I suspect the X, minimize, and maximize buttons on JFrame are also icons since the rest of the JFrame and everything in it got small but those buttons are really big. > I looked back at my notes and it is Java 9 that fixed the Swing scaling issues. Try Java 9 and I think all your problems will be solved. -- Knute Johnson
[toc] | [prev] | [next] | [standalone]
| From | Eric Douglas <e.d.programmer@gmail.com> |
|---|---|
| Date | 2018-01-22 10:17 -0800 |
| Message-ID | <2d18531b-25fd-4923-87a3-a6e80c4b6683@googlegroups.com> |
| In reply to | #37967 |
On Monday, January 22, 2018 at 12:38:51 PM UTC-5, Knute Johnson wrote: > > I looked back at my notes and it is Java 9 that fixed the Swing scaling > issues. Try Java 9 and I think all your problems will be solved. > > -- > > Knute Johnson I will check that out, as soon as our other software package supports 9.
[toc] | [prev] | [next] | [standalone]
| From | Eric Douglas <e.d.programmer@gmail.com> |
|---|---|
| Date | 2018-01-22 12:49 -0800 |
| Message-ID | <18a2624c-57f3-42d8-b1bd-610216c74822@googlegroups.com> |
| In reply to | #37967 |
On Monday, January 22, 2018 at 12:38:51 PM UTC-5, Knute Johnson wrote: > > I looked back at my notes and it is Java 9 that fixed the Swing scaling > issues. Try Java 9 and I think all your problems will be solved. > > -- > > Knute Johnson I can only hope icons scale correctly in Java 9, as they also used a fixed size icon for JOptionPane. This hasn't been an issue in our application thus far, but does look stupid if you set your resolution/scale too far off.
[toc] | [prev] | [next] | [standalone]
| From | Knute Johnson <nospam@rabbitbrush.frazmtn.com> |
|---|---|
| Date | 2018-01-22 15:31 -0600 |
| Message-ID | <p45l6r$5v3$1@dont-email.me> |
| In reply to | #37969 |
On 1/22/2018 14:49, Eric Douglas wrote: > On Monday, January 22, 2018 at 12:38:51 PM UTC-5, Knute Johnson wrote: >> >> I looked back at my notes and it is Java 9 that fixed the Swing scaling >> issues. Try Java 9 and I think all your problems will be solved. >> >> -- >> >> Knute Johnson > > I can only hope icons scale correctly in Java 9, as they also used a fixed size icon for JOptionPane. This hasn't been an issue in our application thus far, but does look stupid if you set your resolution/scale too far off. > The scaling is actually very good. I had a client get a laptop with a very high DPI monitor and he couldn't read the text on the GUI. I had started rewriting the program with a JavaFX GUI when Java 9 showed up with the scaling fix for Swing. He just changed out his runtime and it is back readable again. Java 10 is due in late March, I don't know what that means for 8, whether it will be EOLd then or if there will be a delay on that with the new release schedule. 9 has one really nice feature and that is that you can compile for previous versions with a single command line option. You don't need to have the rt.jar files for all the different versions. I've got some software in the wild that is stuck on Java 8 runtimes for the foreseeable future but I'm using the 9 compiler. -- Knute Johnson
[toc] | [prev] | [next] | [standalone]
| From | j4n bur53 <janburse@fastmail.fm> |
|---|---|
| Date | 2018-01-22 22:37 +0100 |
| Message-ID | <p45lj8$hfb$1@news.albasani.net> |
| In reply to | #37958 |
What Look & Feel, and what platform do you use?
I found that in JDK 8, only the windows classic
and the windows Look & Feel was scaled to the monitor.
But then in JDK 10, it is that also the following
Look & Feels Metal, Nimbus and CDE/Motif are scaled.
At least this is what a quick testing
on Windows 10 machine showed, that has a 2K display:
https://gist.github.com/jburse/c3362733ed08ee2e92db58723d529ad2#file-empty-p
I dunno how they do it inder the hood. On the
Mac plattform, they have the class sun.awt.CGraphicsDevice,
which has a field resp. method getScaleFactor(),
and this is used on the Mac plattform in JDK 8.
Maybe JDK 10 uses another strategy, on both the
Windows and Mac plattform. I could only
identify one further difference between JDK 8
and JDK 10 on the Windows platform, with some
guess work:
1) JDK 8, Windows 10, dragging a window:
If a different monitor is used, the dragged window
changes resolution, as soon as the mouse lands
in the different monitor.
It seems that the resolution change is based
on some buffer scaling, or somesuch. Not
sure, fonts are not fine grained, blured, like
if some interpolation bitmap scaling.
2) JDK 10, Windows 10, dragging a window:
If a different monitor is used, the dragged window
changes resolution, as soon as the mouse is
released.
It seems that the window is re-validated and/or
re-painted, or somsesuch. Not sure, fonts are
much finer. Actually a little bit too fine, as
if antialiasing would missing.
I consider the mouse behaviour in 2) either a bug
or a compromise. Also I need to adapt to the font
display in 2), not used to that fine fonts.
Eric Douglas schrieb:
> I've tried searching and found others had the same problem but no clear solution. I tried digging into the code that draws it but it doesn't look good. I resize a window ie pull up a window on a Surface Pro and set view to 300% and all JComponents change size, except for the box portion of the JCheckBoxes.
>
> This guy had the same problem
> https://arstechnica.com/civis/viewtopic.php?f=20&t=123408
>
> This guy made a hack solution to generate a custom icon instead of using the ones Oracle provided.
> https://stackoverflow.com/questions/22691353/scale-a-jcheckbox-box
>
> Here's another possible hack solution.
> https://stackoverflow.com/questions/4770022/make-jcheckbox-bigger
>
> Every other control is truly dynamic and simply scales when Windows tells it to, why are checkboxes (and apparently radiobuttons) so difficult?
>
[toc] | [prev] | [next] | [standalone]
| From | bursejan@gmail.com |
|---|---|
| Date | 2018-01-22 14:16 -0800 |
| Message-ID | <77323375-95b3-4ea0-8d47-7540f80ac0fb@googlegroups.com> |
| In reply to | #37971 |
The nice thing of the Windows platform solution is, as provided by the JDK 10, the fonts and metrics get all bigger. So that one can simply switch the image of an icon with a higher res image, and then since the width and height of the icon are also bigger, icons are also shown finer. The approach is just to use some logic when providing the URL of an image icon. Unfortunately this doesn't work on the Mac platform, since there they use different values of getScaleFactor(), and then the fonts and metrics dont change much. With the result that image icons look awful. For this purpose some months ago I have furnished a class DenseIcon: The code only works for scale factor = 2, and replacing the underlying icon by a twice as high res icon. For other scale factors the code would need slight adaption. But this seems to work across JDK 8 and JDK 10, here on a Retina Mac machine, and jigsaw gives a warning since we used reflection: On JDK 8: scale factor = 2 On JDK 10: scale factor = 2 WARNING: An illegal reflective access operation has occurred WARNING: Illegal reflective access by omonia.util.comp.DenseIcon (file:/Projects/Omonia/Prototyping/swing/librun/lib/omdev_swing.jar) to method sun.awt.CGraphicsDevice.getScaleFactor() WARNING: Please consider reporting this to the maintainers of omonia.util.comp.DenseIcon WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations WARNING: All illegal access operations will be denied in a future release Unfortunately Swing uses here and then getImage() automatically, for example to provide a blurred icon in a disabled menu item. So that the solution is not perfect. But labels, list and tables etc.. are fine. Am Montag, 22. Januar 2018 22:38:00 UTC+1 schrieb j4n bur53: > What Look & Feel, and what platform do you use? > I found that in JDK 8, only the windows classic > and the windows Look & Feel was scaled to the monitor. > > But then in JDK 10, it is that also the following > Look & Feels Metal, Nimbus and CDE/Motif are scaled. > At least this is what a quick testing > > on Windows 10 machine showed, that has a 2K display: > > https://gist.github.com/jburse/c3362733ed08ee2e92db58723d529ad2#file-empty-p > > I dunno how they do it inder the hood. On the > Mac plattform, they have the class sun.awt.CGraphicsDevice, > which has a field resp. method getScaleFactor(), > > and this is used on the Mac plattform in JDK 8. > Maybe JDK 10 uses another strategy, on both the > Windows and Mac plattform. I could only > > identify one further difference between JDK 8 > and JDK 10 on the Windows platform, with some > guess work: > > 1) JDK 8, Windows 10, dragging a window: > If a different monitor is used, the dragged window > changes resolution, as soon as the mouse lands > in the different monitor. > > It seems that the resolution change is based > on some buffer scaling, or somesuch. Not > sure, fonts are not fine grained, blured, like > if some interpolation bitmap scaling. > > 2) JDK 10, Windows 10, dragging a window: > If a different monitor is used, the dragged window > changes resolution, as soon as the mouse is > released. > > It seems that the window is re-validated and/or > re-painted, or somsesuch. Not sure, fonts are > much finer. Actually a little bit too fine, as > if antialiasing would missing. > > I consider the mouse behaviour in 2) either a bug > or a compromise. Also I need to adapt to the font > display in 2), not used to that fine fonts. > > Eric Douglas schrieb: > > I've tried searching and found others had the same problem but no clear solution. I tried digging into the code that draws it but it doesn't look good. I resize a window ie pull up a window on a Surface Pro and set view to 300% and all JComponents change size, except for the box portion of the JCheckBoxes. > > > > This guy had the same problem > > https://arstechnica.com/civis/viewtopic.php?f=20&t=123408 > > > > This guy made a hack solution to generate a custom icon instead of using the ones Oracle provided. > > https://stackoverflow.com/questions/22691353/scale-a-jcheckbox-box > > > > Here's another possible hack solution. > > https://stackoverflow.com/questions/4770022/make-jcheckbox-bigger > > > > Every other control is truly dynamic and simply scales when Windows tells it to, why are checkboxes (and apparently radiobuttons) so difficult? > >
[toc] | [prev] | [next] | [standalone]
| From | bursejan@gmail.com |
|---|---|
| Date | 2018-01-22 14:18 -0800 |
| Message-ID | <45ba078c-2e14-4890-897d-c617ac9755ab@googlegroups.com> |
| In reply to | #37974 |
Sorry forgot links, was testing the Mac thingy with; JDK 10 Early-Access Builds http://jdk.java.net/10/ Java Class DenseIcon https://gist.github.com/jburse/bf66f9e84104ad7cfdd5c04fdbaa68c9#file-denseicon-java Am Montag, 22. Januar 2018 23:16:38 UTC+1 schrieb burs...@gmail.com: > The nice thing of the Windows platform solution is, as > provided by the JDK 10, the fonts and metrics get all > bigger. So that one can simply switch the image of an > > icon with a higher res image, and then since the width > and height of the icon are also bigger, icons are also > shown finer. The approach is just to use some logic > > when providing the URL of an image icon. Unfortunately > this doesn't work on the Mac platform, since there they use > different values of getScaleFactor(), and then the > > fonts and metrics dont change much. With the result > that image icons look awful. For this purpose some > months ago I have furnished a class DenseIcon: > > The code only works for scale factor = 2, and replacing > the underlying icon by a twice as high res icon. For other > scale factors the code would need slight adaption. > > But this seems to work across JDK 8 and JDK 10, > here on a Retina Mac machine, and jigsaw gives > a warning since we used reflection: > > On JDK 8: > scale factor = 2 > > On JDK 10: > scale factor = 2 > WARNING: An illegal reflective access operation has occurred > WARNING: Illegal reflective access by omonia.util.comp.DenseIcon (file:/Projects/Omonia/Prototyping/swing/librun/lib/omdev_swing.jar) to method sun.awt.CGraphicsDevice.getScaleFactor() > WARNING: Please consider reporting this to the maintainers of omonia.util.comp.DenseIcon > WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations > WARNING: All illegal access operations will be denied in a future release > > Unfortunately Swing uses here and then getImage() automatically, > for example to provide a blurred icon in a disabled menu item. > So that the solution is not perfect. But labels, list and tables > etc.. are fine. > > Am Montag, 22. Januar 2018 22:38:00 UTC+1 schrieb j4n bur53: > > What Look & Feel, and what platform do you use? > > I found that in JDK 8, only the windows classic > > and the windows Look & Feel was scaled to the monitor. > > > > But then in JDK 10, it is that also the following > > Look & Feels Metal, Nimbus and CDE/Motif are scaled. > > At least this is what a quick testing > > > > on Windows 10 machine showed, that has a 2K display: > > > > https://gist.github.com/jburse/c3362733ed08ee2e92db58723d529ad2#file-empty-p > > > > I dunno how they do it inder the hood. On the > > Mac plattform, they have the class sun.awt.CGraphicsDevice, > > which has a field resp. method getScaleFactor(), > > > > and this is used on the Mac plattform in JDK 8. > > Maybe JDK 10 uses another strategy, on both the > > Windows and Mac plattform. I could only > > > > identify one further difference between JDK 8 > > and JDK 10 on the Windows platform, with some > > guess work: > > > > 1) JDK 8, Windows 10, dragging a window: > > If a different monitor is used, the dragged window > > changes resolution, as soon as the mouse lands > > in the different monitor. > > > > It seems that the resolution change is based > > on some buffer scaling, or somesuch. Not > > sure, fonts are not fine grained, blured, like > > if some interpolation bitmap scaling. > > > > 2) JDK 10, Windows 10, dragging a window: > > If a different monitor is used, the dragged window > > changes resolution, as soon as the mouse is > > released. > > > > It seems that the window is re-validated and/or > > re-painted, or somsesuch. Not sure, fonts are > > much finer. Actually a little bit too fine, as > > if antialiasing would missing. > > > > I consider the mouse behaviour in 2) either a bug > > or a compromise. Also I need to adapt to the font > > display in 2), not used to that fine fonts. > > > > Eric Douglas schrieb: > > > I've tried searching and found others had the same problem but no clear solution. I tried digging into the code that draws it but it doesn't look good. I resize a window ie pull up a window on a Surface Pro and set view to 300% and all JComponents change size, except for the box portion of the JCheckBoxes. > > > > > > This guy had the same problem > > > https://arstechnica.com/civis/viewtopic.php?f=20&t=123408 > > > > > > This guy made a hack solution to generate a custom icon instead of using the ones Oracle provided. > > > https://stackoverflow.com/questions/22691353/scale-a-jcheckbox-box > > > > > > Here's another possible hack solution. > > > https://stackoverflow.com/questions/4770022/make-jcheckbox-bigger > > > > > > Every other control is truly dynamic and simply scales when Windows tells it to, why are checkboxes (and apparently radiobuttons) so difficult? > > >
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.java.programmer
csiph-web