I’ve finally finished the 1st version of my very first JME desktop application.
It works smoothly in every computer except in Mac Os.
The software is made with JME + Swing (for the GUI).
The guy who reported this problem is using a MacBookPro with a Retina display.
When he tries to open the application, he just sees a white screen and the software stops working if he tries to resize the window.
I haven’t added a crash reporter yet, so the only log he could send is this:
Date/Time: 2014-09-14 19:45:43 -1000
OS Version: 10.9.4 (Build 13E28)
Report Version: 18
Path: /Library/Internet Plug-ins/JavaAppletPlugin.plugin/Contents/Home/bin/java
Version: ??? (???)
Parent: Jar Launcher 
Responsible: Jar Launcher 
@Empire Phoenix said:
The problem here is probably, that with retina the real resolution and the reported ones do not match at all.
Workaround would be to simple disallow resizing on macosx for now, and make it via an settings dialog only initial.
Wich exactl jvm version is running? older ones have no real support for retina and use the blurring fallback mode.
Did you try with a simplified testcase? Eg. only the swing frame with the context in it, but without your application logic, to rule out errors there?
I think @normen is using mac as well? Maybee he can confirm this.
Thanks Empire Phoenix for the answer!
He said he’s running Java 7 update 67, so it shouldn’t be because of the Java version.
I’ll try with a testcase (just GUI+JME without any logic) but I don’t own a Mac and for this reason it will be difficult for me.
The weirdest thing is that the application is a completely white screen immediately (so no one is actually resizing it).
Waiting for @normen then, he could know what’s happening
Use AWT panels, this is probably related to the new way of LWJGL to paint into AWT windows natively. AWT panels will also allow you to open more than one jME window in a swing app. You could also try and use a newer LWJGL version, maybe they fixed the issue by now. But you’d have to create your own jME3-lwjgl-natives.jar for that from the binaries.
Use AWT panels, this is probably related to the new way of LWJGL to paint into AWT windows natively. AWT panels will also allow you to open more than one jME window in a swing app. You could also try and use a newer LWJGL version, maybe they fixed the issue by now. But you'd have to create your own jME3-lwjgl-natives.jar for that from the binaries.
Forgive my ignorance,
I’m using several Swing components and JPanels to make the main structure. What should I exactly replace with the AWT panels?
Also how can I check the LWJGL version that JMonkeyEngine is using right now?
Check the AWT panels example, jME uses lwjgl 2.9.0 by default.
Thanks Normen for the really useful answers,
I have checked both things.
Seems that lwjgl 2.9.1 has the possibility to enable HighDPI from VM parameter and from code before creating the Display ( http://www.lwjgl.org/wiki/index.php?title=Using_High_DPI_Mode ).
The problem is that I’m not directly creating the Display (JME does it) and I don’t know where I could add the code to make it run correctly (I would also need to check if the display is a Retina, but this shouldn’t be a problem).
This is probably the best way to fix it, although I’m not really sure how to create the .jar from the binaries.
The awt panel is basically a better Canvas, which could allow us to open many JME windows but I’m sure it won’t really solve the problem.
So the 2 final questions now are:
how can I add in my application “System.setProperty(“org.lwjgl.opengl.Display.enableHighDPI”, “true”);” before the Display creation?
how do I create my own jME3-lwjgl-natives.jar from the binaries?
I would just need any reference or documentation
sorry for the late reply, I have been pretty busy these days!
I have done several tests and I’ve discovered that my problem (of Canvas position) is common in all Macs (Retina and non-Retina).
So far I’ve:
tried to fix the Canvas in the GUI adding a JPanel as container of the Canvas, but it didn’t do much
tried to force Revalidation of the Canvas and the parent component (the JPanel)
tried the AWT Panel provided in JME (but seems that you cannot attach and detach the AWTPanel dinamically, which is really needed for me)
I don’t know if it’s a jME3-lwjgl library bug, but it works perfectly on Windows and Linux.
Do you guys have any tip? I’ve seriously run out of ideas
After many sad other tests, this is what happens now:
When you open the program, the canvas is in the wrong place (top-left corner of the window, intead of the center (I’m using BorderLayout.CENTER for it)).
If you just resize the window, the canvas will stay in the top-left corner.
If you switch tab, the GUI won’t refresh correctly (except for the canvas which refreshes dimensions but it is still in the wrong position), like if the canvas existence is blocking the SWING repainting process.
If you switch tab AND resize the window, the GUI is correctly refreshed and the canvas is in the right place (so in this case it works, but I don’t get why).
From these 3 points (which happen on Macs only) I suppose that when switching tab+resizing the window something happen in Swing process. We would need to call this “something” every time, but we don’t know which methods are called.
Again, any little try or help would be really useful,
Yes, you’re right, it must be for sure the right way. But I have 2 problems:
AWT panel is unloaded when I detach it (I need to reattach in another tab everytime the user changes tab)
AWT panel seem to thread lock at the beginning: I create the AWT Panel (so the LWJGL thread) and start the JME app. Then I create my Swing GUI which requires some data from the JME thread (which is supposely the LWJGL thread) and the software just freezes.
Are there solutions for those 2 problems?
Otherwise, is there a way for coding my own JPanel which actually behaves like the AWT panel?