问题
In the Haxe.java api at http://api.haxe.org/java/index.html, there does not appear to be any support for graphics, windowing, or user-interactive events.
There used to be: http://old.haxe.org/doc/java/graphics2d (note the "old"), but we can't use these libraries anymore:
import java.awt.Graphics; // Compile time error: Class not found : java.awt.Graphics.
import java.awt.*; // this works, but so does import java.nonExistantPackage.*;
Does Haxe still have java graphics support? If so, how can we use it?
Note: I installed java successfully:
haxelib install hxjava
Edit:
There IS access to java.awt et al (through hxjava). The unusual part is the error message when targeting a different platform: instead of "can't access x while targeting y" it is "can't find x". This is very confusing since I tested the existence of the api by using an import statement without changing the target.
回答1:
Yes, you can use java.awt.*
and javax.swing.*
packages.
Here's a gist including the basics from Justinfront's code on the old Haxe site that you referred to.
https://gist.github.com/cambiata/d025fc7e66352a0b0681
I testrun it a minute ago, using Haxe 3.1.3 and hxjava 3.1.0 - no problem. Hope this helps!
回答2:
The swing/awt or lwjgl are covered here http://old.haxe.org/doc/java
then there is stuff in my github... https://github.com/Justinfront/hx_swing_examples
https://github.com/Justinfront/wwx2014_justinfront/blob/master/src/wwx2014_justinfront/bouncinglogo/BouncingLogo_swing.hx
https://github.com/Justinfront/wwx2014_justinfront/blob/master/src/wwx2014_justinfront/bouncinglogo/BouncingLogo_lwjgl.hx
https://github.com/Justinfront/YouTube-tutorials-haxeJava
I looked at some other approaches and JavaFX is not easily supported and Libgdx was breaking but hopefully they will find better support later, I believe processing has been used by AndyLi but not tried. I am not too sure on Android approaches but Libgdx seems an interesting future one, but I think some have done some pure haxe android java maybe look at some of Hugh's work that he mixes in with nme.
来源:https://stackoverflow.com/questions/26877474/haxe-java-windowing