Demande d'aide pour tester AL - Swing - JavaFX
Bonjour à tous,
Comme vous le savez sans doute, je travail pas mal en ce moment sur mon petit projet AL et plus particulièrement sur l'implémentation du JSR-223 que j'ai appelé AL-Script.
Grâce à pas mal d'introspection etc, je parvient maintenant à créer des fenêtre swing directement depuis AL et même créer des écrans en JavaFX.
Seulement voilà quand on est seul, on n'arrive pas à tout tester, et comme je sais que parmis vous il y a des gens super calé dans ces technos, je voulais savoir si ça en intéréssez certains à m'aider à tester un peu tout ça ?????
Pour mieux comprendre, voici les code sources que j'obtiens pour créer du swing :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
|
public static void main(String[] args) throws ScriptException {
String source = ""
+ ""
+ "set UIManager = java.newObject (\"javax.swing.UIManager\", \"FrameDemo\");"
+ "UIManager.setLookAndFeel(\"com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel\");"
+ ""
+ "set frame = java.newObject (\"javax.swing.JFrame\", \"FrameDemo\");"
+ "frame.setDefaultCloseOperation(frame.EXIT_ON_CLOSE);"
+ ""
+ "set pane = frame.getContentPane();"
+ "pane.setLayout(java.null);"
+ ""
+ "set insets = frame.getInsets();"
+ "print (insets.getTop());"
+ "insets.setTop(15);"
+ "insets.setBottom(15);"
+ "insets.setLeft(15);"
+ "insets.setRight(15);"
+ ""
+ "set button = java.newObject (\"javax.swing.JButton\", \"Say Al'O !\n\");"
+ "button.addActionListener(function (e, name) {"
+ " print (\"Action Command \" .. e.getActionCommand());"
+ " print (\"From method \" .. name);"
+ " print (\"Al'O world !\");"
+ " textArea.append(\"Al'O world!\n\");"
+ " "
+ "});"
+ ""
+ "set size = button.getPreferredSize();"
+ "button.setBounds(25 + insets.getLeft(), 25 + insets.getTop(), size.getWidth(), size.getHeight());"
+ "pane.add (button);"
+ ""
+ "set textArea = java.newObject (\"javax.swing.JTextArea\");"
+ "textArea.setBounds(25 + insets.getLeft(), 75 + insets.getTop(), 700, 400);"
+ "pane.add (textArea);"
+ ""
+ ""
+ "frame.setSize(800, 600);"
+ "frame.setVisible(true);"
+ ""
+ "";
ScriptEngineManager manager = new ScriptEngineManager();
ScriptEngine alEngine = manager.getEngineByName("al");
alEngine.eval(source);
} |
et du JavaFX
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
|
public class JavaFXApplication3 extends Application {
@Override
public void start(Stage primaryStage) throws ScriptException {
String source = ""
+ "set btn = java.newObject (\"javafx.scene.control.Button\");"
+ "btn.setText (\"Say Al'O world !\");"
+ "btn.setOnAction (function () {"
+ " print (\"Say Al'O world !\");"
+ "});"
+ ""
+ "set root = java.newObject (\"javafx.scene.layout.StackPane\");"
+ "root.getChildren().add(btn);"
+ "print (root.getChildren());"
+ ""
+ "set scene = java.newObject (\"javafx.scene.Scene\", root, 300, 250);"
+ "primaryStage.setScene(scene);"
+ "primaryStage.setTitle(\"Al'O World!\")"
+ "primaryStage.show();"
+ "";
ALScriptEngine alEngine = new ALScriptEngine();
alEngine.put("primaryStage", primaryStage);
alEngine.eval(source);
}
public static void main(String[] args) {
launch(args);
}
} |
Voilà....
Alors, les intéressés, faites vous connaître.
Merci d'avance ;-)