Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

jerwin

Suspended
Original poster
Jun 13, 2015
2,895
4,652
Quite recently, I looked into learning javaFX-- as I had a Swing program that was sort of pushing up against the limitations of that library.

So... HelloWorld in JavaFX.

http://docs.oracle.com/javafx/2/get_started/hello_world.htm

What it's supposed to look like:

helloworld.png


What it actually looks like:

Screen Shot 11.png

Anybody know what's going on? (This happens even if the code is pasted in directly from the code listing-- something I try as the last resort when learning to code.)

Finally, I suppose I should ask-- does JavaFX have a future?
 
I don't use JavaFX, so all I have is a few questions, and a rough idea.

First:
What OS version?
What Java version?

Second:
Is this on a Mac with a retina-type display?

In your screenshot, I measured a Mac window content area of about 600 x 500 pixels. The code in the example has this line:
Code:
       primaryStage.setScene(new Scene(root, 300, 250));

Notice the args 300 and 250 are exactly twice the apparent content area size. To me, this suggests retina-type display handling, where there are 2 linear pixels on the display for each linear point (typographic point, not Cartesian).

The problem seems to be that the placement (and possibly the scaling) of the content within the Scene is incorrect. It looks off by roughly a factor of 2. This is a rough guess, obtained by estimating the center of the button being at the lower-right corner of the displayed content area.

After a little googling, it seems that "HiDPI" is the term used by JavaFX. Here's the search terms I used, and some results:
mac javafx hi dpi
http://stackoverflow.com/questions/26182460/javafx-8-hidpi-support
http://apple.stackexchange.com/questions/53741/java-and-mac-retina-support


To me, this looks like a graphics scaling bug. Unfortunately, it could be in any of several places.

It might be in the version of Java you're using. It might be in the OS version you're using. It might be the particular combination of Java and OS versions, i.e. the bug might only appear when both versions are what you have, and not appear on different combinations of OS and Java.

Some things I'd try in this situation:

Try some of the other JavaFX examples and see if they misbehave the same way.

Try a different version of Java on your current OS version.

Try a different OS version on this version of Java.

Look into how JavaFX does graphical scaling (zoom) and/or Hi-DPU, and see if you can add code to the example that alters it. For example, change the scaling in the Scene to 50% and see what happens. Or force Hi-DPI to be enabled.

Check the Java or JavaFX bug database for reported bugs with default scaling on Mac OS.


Finally, I suppose I should ask-- does JavaFX have a future?
Hard to be certain.

I noticed the link you provided has a last-modified data of Sep 2013. Things might be different now that JavaFX is an integrated part of the Java 8 download.

It may even be that older examples won't work right. It could be worthwhile to try finding newer examples, such as ones that specifically target Java 8.
 
I apologize. Apparently this bug was fixed in a subrelease of Java, which I hadn't yet installed. Possible as far back as Java8u60. The latest release of Java 8 is 8u112
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.