My favorites | Sign in
Project Logo
                
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
49
50
51
52
53
54
55
56
57
58
/*
* Created on Dec 30, 2008
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*
* Copyright @2008 the original author or authors.
*/
package org.fest.javafx.desktop.launcher;

import javafx.stage.Stage;

import javax.swing.JFrame;

import com.sun.javafx.runtime.TypeInfo;
import com.sun.javafx.runtime.sequence.Sequence;

import org.fest.swing.annotation.RunsInEDT;
import org.fest.swing.edt.GuiQuery;

import static org.fest.javafx.desktop.util.Windows.frameFrom;
import static org.fest.reflect.core.Reflection.staticMethod;
import static org.fest.swing.edt.GuiActionRunner.execute;

/**
* Understands how to start a compile JavaFX UI.
*
* @author Alex Ruiz
*/
public final class JavaFxClassLauncher {

/**
* Launches the given compiled JavaFX UI and returns the <code>{@link JFrame}</code> hosting the JavaFX UI.
* @param javaFxClass the class containing the JavaFX UI to launch.
* @return the <code>JFrame</code> hosting the JavaFX UI once it's started.
*/
@RunsInEDT
public static JFrame launch(final Class<?> javaFxClass) {
Stage stage = execute(new GuiQuery<Stage>() {
protected Stage executeInEDT() throws Throwable {
return (Stage) staticMethod("javafx$run$").withReturnType(Object.class)
.withParameterTypes(Sequence.class)
.in(javaFxClass)
.invoke(TypeInfo.String.emptySequence);
}
});
return frameFrom(stage);
}

private JavaFxClassLauncher() {}
}
Show details Hide details

Change log

r2126 by Alex.Ruiz.05 on Dec 31, 2008   Diff
Incomplete - task 275: [fest-javafx] Find
a way to start a JavaFX UI from a Java
test case
http://code.google.com/p/fest/issues/detai
l?id=275

* Moved launchers to package
org.fest.javafx.desktop.launcher
* JavaFXClassLauncher now is executed in
the event dispatch thread
* ScriptLauncher returns the JFrame
hosting the started JavaFX UI
Go to: 
Project members, sign in to write a code review

Older revisions

r2123 by Alex.Ruiz.05 on Dec 30, 2008   Diff
Incomplete - task 275: [fest-javafx]
Find a way to start a JavaFX UI from a
Java test case
http://code.google.com/p/fest/issues/d
etail?id=275
...
All revisions of this file

File info

Size: 2134 bytes, 58 lines
Hosted by Google Code