Draque Thompson

Ranch Hand
+ Follow
since May 31, 2018
Draque likes ...
Netbeans IDE Python Java
Merit badge: grant badges
For More
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Draque Thompson

Thank you for pointing this out! I had seen this answer before, but didn't read past the first answer, as it didn't seem to have everything I needed. Below is the specific solution I came up with in case anyone ever needs it and runs across this thread:
(Also, it goes without saying, but this code will blow up in a headless environment, so be aware of that when making testing.)

1 year ago
The complicating factor here is that I need to be able to tell this with an arbitrary number of monitors. I have done some testing with , but that only gives me the resolution of the main monitor. The coordinates go negative in the x dimension when I call with the window on the other monitor.

I'm kind of scratching my head as to how to test for this, as my program saves window location, but if a user changes their monitor configuration, that can lead to windows popping off screen. Any ideas appreciated.
1 year ago
Well shoot, I had found some of the same things, but had hoped that there was some simple workaround that I might be able to implement for macs. The most I was able to do is make the whole program look blurry when the OS auto resizes it.

Anyhow, the program I am implementing this for is fairly mature at this point, with extensive UIs. Reworking that all into Jfx is unfortunately a way bigger task that I could take on at the moment. It would be a neat feature, but Mac users are only about 1/5 of my relatively small user base ad it stands.

Thank you for the help, though! It’ll be a nice feature for my Windows users and a godsend for anyone with a modern display on Linux!
2 years ago
Update on this one.

UI Scaling seems to simply not work on macOS in particular. The code posted above does work in Linux, which was my biggest issue. I am still trying to get this to work in macOS simply to give users an additional feature, though.

In Windows and Linux, adding this in the beginning of the main method will change the scaling appropriately, pulling from my program's options:

However this is ignored in macOS. It was suggested elsewhere online that I try each of the below, but neither of these work either:

and conversely

After doing some digging, I found that macOS handles its own scaling, which actually seems to cancel out any changes that I make to the scaling. Is there any way to turn off the macOS scaling through VM options? If it's not possible, this option might simply not be available for mac users, but I would like to provide it for everyone.

Also, thank you for the help so far, it steered me in the direction I needed! ^^
2 years ago

Stephan van Hulst wrote:Okay, here's what I figured out so far:
use the add-options plugin.

Alright, this is progress, thank you! Obviously this builds it into the linked/packaged file though. Do you know if there is any way to modify the value on startup before any of the graphics for my application are initialized? That would allow this to be set in the options menu of my program/be respected on program restart.

EDIT: I have tried adding the below to the program's main() function, but that does not seem to work.

2 years ago
Ahh, sure thing! I am hoping that I can set this up somewhere other than the actual jlink step, as I would really like to have this be a scalable feature, but if I need to, I can make due with a process that produces a number of differently scaled executables (for Linux in particular). I didn't bother including everything on the module path below, but if it would be helpful, I can expand that to show everything.

2 years ago
Oh jeez, I should have included that.

It’s running on Java 17, and I build executable binaries by building then using jlink to package everything up. So if I’m starting it in Windows, I just do so by opening the app’s exe file.
2 years ago
I have an application which I would like to scale the UI of. Initially, this was just something that I wanted to offer for Linux users (as dynamic scaling seems to simply not work any more in Ubuntu), but I realized if I was going to code it, I might as well flesh it out a bit more.

I have found some VM arguments across the web that folks have told me to set, but none of those are changing the scaling when I actually run the program (and I've tried in both macOs and Ubuntu).

Ideally, I would like to have an options menu set up where you can enter in a scaling value. I realize that it might require a restart of the program for this to take effect, but I am still having trouble getting this to work.

Also, given that I use jlink to create a binary for my distribution, is there a good way to dynamically decide what VM arguments to hand in? I wish I had more code to share here, as that's typically a starting point, but I feel like this might be something which is set up entirely outside the source of my project.

Any help much appreciated.
2 years ago
I am not 100% sure why, but the paint method on the base object just does not get called as you would expect. The synth object’s does though. I’m not certain what might have caused the difference in functionality.
2 years ago
Just as a followup to this one, I did end up coming up with a solution, even if it's suboptimal. The solution is specifically for Windows, obviously.

2 years ago
As a heads up, this is both a problem and a solution. I upgraded from Java 14 to 17 in my app and I began to see wildly inconsistent functioning of my custom tooltips, with zero functionality whatsoever in Windows. Below is both the problem state and the solution in case anyone runs into the same issues and needs a fix.

In the past, two snippits of code would give you customized tooltips.

Somewhere in startup for your program:

With the class CustomToolTipUI defined like this:

I don't know when this changed, but once I went to J17, things stopped working as they had. ToolTips took 30-45 secoonds to appear at all on macOS/Linux, methods were not firing as expected, and they were 100% kaput on Windows. To correct the problems, update the class you're extending to SynthToolTipUI, and swap out the typical paint() method for an overidden, protected method. I included a line snagging the JComponent from the context simply to show that you can use identical code otherwise. If the traditional paint() method is called, it will automatically drop down to the newly defined one here, so there's no need to override that.


2 years ago

Do you mean the locations of all installed fonts? I'm pretty sure there are published rules for directories used by Windows.

Blorf. I think I'm going to have to end up making a special case for this that detects when the windows/fonts folder is hit and manually populates the view of Windows/Fonts based on this X(. Anyhoo, it's only a problem for Windows, but it's a problem that I unfortunately need to address before my next release.

Once I have a solution, I'll post it here so that anyone finding this thread won't be left in the cold if they have the same problem.
2 years ago

This seems like something the Java maintainers ought to be able to fix. But in practice that ain't gonna happen, so yes, unfortunately it's up to you.

This times infinity. I have filed multiple bug reports, and there's actually an old post here where I specify code which specifically circumvents this exact problem with seteps to reproduce and correct... but the tickets are silently closed.

Solution if you're interested: https://coderanch.com/t/694808/java/Font-Ligatures-Swing-Display-Objects

As far as ligatures go, I know of absolutely no reason why when you present a ligature Unicode code point that Java would not render it as a ligature.

I'm not sure what the underlying cause is, but the workaround is linked above. When I load it in any way other than pulling the binary directly and manually turning the ligatures on, it fails to load them properly in many fonts. This is a bug in Java that I've been reporting without avail to Oracle for years, unfortunately.

Does anyone happen to know how to request the virtual file locations from Windows? I can make a workaround window that searches for the actual files and presents users with a custom menu... but that would be sloppy.
2 years ago
Thank you for the replies there! I have done some digging of my own and found that the contents Fonts folder is actually completely virtual. Explorer itself knows to populate it with values from elsewhere. All fonts are stored in individual folders with esoteric names within c:/Windows/WinSxS.

So given that the fonts folder is virtual... anyone know a good way to read that manually? I have been getting complaints from my users, and would really like to be able to integrate this better, especially for folks who know enough to go to a specific folder to pick out a font.

Also, @Paul Clapham I've gone down that path already, and unfortunately need to do things this way. Java does not load ligatures properly for all OSes and font types unless you load directly from the binary file, which impacts my users in particular. I need to be able to present them with a standard UI.
2 years ago
Windows users of my application are having a problem seeing files in a folder with the default JFileChooser. Specifically when they browse to the C:\Windows\Fonts folder, it appears empty. When browsing to other folders,

I suspect this is some sort of invisible permissions issue, but I am having trouble figuring out how to nail this down or request permissions on the folder to allow its contents to be seen. Is this something that anyone else here has dealt with? The code I'm using is all very standard, but I'm including it below just for completeness. I am using Java 17 at this point.

And I hope everyone is having a good holiday! Writing this from bus station as I wait for my ride back to family.
2 years ago