Skip to content

Commit a14487b

Browse files
author
Wenjun Che
committed
ADAP-16: Embedding example
1 parent abb4a19 commit a14487b

1 file changed

Lines changed: 63 additions & 1 deletion

File tree

README.md

Lines changed: 63 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# java-example
22
Examples for OpenFin Java adapter
33

4-
## Run the example
4+
## Run the example of connecting to OpenFin and creating applications
55

66
1. Clone this repository
77

@@ -74,6 +74,68 @@ Source code for the example is located in /src/main/java/com/openfin/desktop/dem
7474
}
7575
});
7676

77+
## Run the example of docking Java Swing window with HTML5 application
78+
79+
1. Clone this repository
80+
81+
2. Go to release directory and start docking.bat
82+
83+
3. Once the java app starts, click on "Launch OpenFin" button, which should start OpenFin Runtime and "Hello OpenFin" HTML5 demo app. The java app will wait and try to connect to OpenFin Runtime.
84+
85+
4. After clicking "Dock to HTML5 app" button, you can move either window to see docking effect.
86+
87+
5. Click "Undock from HTML5 app" to undock 2 windows
88+
89+
## Source Code Review for docking windows
90+
91+
Source code for the example is located in /src/main/java/com/openfin/desktop/demo/OpenFinDockingDemo.java. The followings overview of how it communicates with OpenFin Runtime with API calls supported by the Java adapter:
92+
93+
1. Create connection object:
94+
95+
this.controller = new DesktopConnection("OpenFinDockingDemo", "localhost", port);
96+
97+
This code just creates an instance and it does not try to connect to runtime.
98+
99+
2. Launch and connect to OpenFin runtime:
100+
101+
controller.launchAndConnect(this.desktopCommandLine, listener, 10000);
102+
103+
listener is an instance of DesktopStateListener which provides callback on status of connections to runtime. desktopCommandLine is a string of arguments passed to OpenFinRVM.
104+
This example by default passes remote config file for Hello OpenFin app, which will be started as the first app in OpenFin Runtime.
105+
106+
3. dockToStartupApp and undockFromStartupApp show to dock and undock 2 windows.
107+
108+
109+
## Run the example of embeding HTML5 application to Java Swing window with awt.canvas
110+
111+
1. Clone this repository
112+
113+
2. Go to release directory and start embedding.bat
114+
115+
3. Once the java app starts, click on "Launch OpenFin" button, which should start OpenFin Runtime and "Hello OpenFin" HTML5 demo app. The java app will wait and try to connect to OpenFin Runtime.
116+
117+
4. You can click "Embed HTML5 app" button bring HTML5 window into Swing window.
118+
119+
## Source Code Review for embedding windows
120+
121+
Source code for the example is located in /src/main/java/com/openfin/desktop/demo/WindowEmbedDemo.java. The followings overview of how it communicates with OpenFin Runtime with API calls supported by the Java adapter:
122+
123+
1. Create connection object:
124+
125+
this.controller = new DesktopConnection("OpenFinDockingDemo", "localhost", port);
126+
127+
This code just creates an instance and it does not try to connect to runtime.
128+
129+
2. Launch and connect to OpenFin runtime:
130+
131+
controller.launchAndConnect(this.desktopCommandLine, listener, 10000);
132+
133+
listener is an instance of DesktopStateListener which provides callback on status of connections to runtime. desktopCommandLine is a string of arguments passed to OpenFinRVM.
134+
This example by default passes remote config file for Hello OpenFin app, which will be started as the first app in OpenFin Runtime.
135+
136+
3. embedStartupApp method shows to embed HTML5 app to Swing window.
137+
138+
77139
## More Info
78140

79141
More information and API documentation can be found at https://www.openfin.co/developers.html?url=developers/api/java/overview.html

0 commit comments

Comments
 (0)