Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #37974

Re: How do you scale a JCheckBox?

Newsgroups comp.lang.java.programmer
Date 2018-01-22 14:16 -0800
References <316fc0bc-d954-41c1-b913-3dd6e52e902a@googlegroups.com> <p45lj8$hfb$1@news.albasani.net>
Message-ID <77323375-95b3-4ea0-8d47-7540f80ac0fb@googlegroups.com> (permalink)
Subject Re: How do you scale a JCheckBox?
From bursejan@gmail.com

Show all headers | View raw


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?
> >

Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

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

csiph-web