I have been prototyping an idea I have for an app, but as I'm a better Swing developer than app developer, I am doing it using Swing. I wanted to allow it to embed a video using JavaFX MediaPlayer/JFXPanel in a JDialog, and I'm almost there. It does embed it, but it then shrinks all my Swing components. The JFXPanel is sized as I would expect, but all my swing components are scaled down. I have to stretch the JDialog pane to see all the components, and the fonts are all small etc. I was having trouble searching for an answer to this but if this is a duplicate question I'd appreciate a pointer to the answer. Here are some images.
I tried various things, such as not embedding it at all, but bringing the video up in separate JFrame , I tried NOT using JFXPanel, etc. The embedding got me closer than anything else I tried. I have tried setting MinimumSize and PreferredSize for my Swing components etc. It just scales it all down tiny.
Edit: I checked Screen Size using
Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
System.out.println("screensize "+screenSize.getWidth() + " by "+screenSize.getHeight());
When I put this code in the main Swing class I get
screensize 1536.0 by 864.0
But in the SceneGenerator Class, in the createScene method I get
screensize 3840.0 by 2160.0
As soon as I create a scene, it thinks I have a much higher resolution machine. I don't know how to fix it. I need consistency! :)



Okay. Here's the Kludgy solution.
In my Main Screen constructor (a JPanel class), I create a scene with a default video. That changes the DPI. Then I set my sizes anew by multiplying what it wanted to be under Swing, by the ratio of the new (fx) dpi over the original (swing) dpi. This fixes the problem and since this is just a silly prototype for demo purposes, I'm okay with this. This will never be operational code. If I find someone who wants to develop my App, they will want to use real computer scientists.
However, if someone has a REAL solution to this, either using CSS or some other solution, please pipe up!