|
1 | 1 | # java-example |
2 | 2 | Examples for OpenFin Java adapter |
3 | 3 |
|
4 | | -## Run the example |
| 4 | +## Run the example of connecting to OpenFin and creating applications |
5 | 5 |
|
6 | 6 | 1. Clone this repository |
7 | 7 |
|
@@ -74,6 +74,68 @@ Source code for the example is located in /src/main/java/com/openfin/desktop/dem |
74 | 74 | } |
75 | 75 | }); |
76 | 76 |
|
| 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 | + |
77 | 139 | ## More Info |
78 | 140 |
|
79 | 141 | More information and API documentation can be found at https://www.openfin.co/developers.html?url=developers/api/java/overview.html |
|
0 commit comments