I have a java desktop application which uses java swing and it works fine with normal displays.
But when come to ~hiDpi~ displays( 3200*1800) whole
I don't have ready solution, but:
If your elements are in a JPanel in JFrame (standard way), write your own Layout Manager, that scales this root Jpanel to 1/4 of size of JFrame, and make the JFrame bigger four times in size (width x 2, lenght x 2).
Override painting methods in JFrame, and some logic with getGraphics() (you need to investigate that), ensure, that method setScale(2,2) is invoked on graphics before it is given to drawing code, it will make everything draw four times bigger.
Use java.awt.EventQueue, write your own EventQueue that will proxy all mouse events, and translate them to be 1/4 of the original position in window(x/2, y/2), then let them go, they should fire events on proper elements.
The whole idea is to let the components stay in their original size (virtually), but scale drawing code and mouse events, so it should look and work same way as on lower resolution displays.