Skip to content

Commit 03ed0b8

Browse files
committed
ADAP-148: add S&D example for FX windows
1 parent 7bc152d commit 03ed0b8

File tree

4 files changed

+7
-24
lines changed

4 files changed

+7
-24
lines changed
235 Bytes
Binary file not shown.
-1015 Bytes
Binary file not shown.

src/main/java/com/openfin/desktop/demo/FxLayoutFrame.java

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ public FxLayoutFrame(DesktopConnection desktopConnection, String appUuid, String
2626
this.windowName = windowName;
2727
if (jFXPanel == null) {
2828
jFXPanel = new JFXPanel();
29+
javafx.application.Platform.setImplicitExit(false);
2930
}
3031
javafx.application.Platform.runLater(new Runnable() {
3132
@Override
@@ -47,12 +48,8 @@ public void run() {
4748
FxLayoutFrame.this.stage.setY(480);
4849
FxLayoutFrame.this.stage.show();
4950

50-
FxLayoutFrame.this.stage.setOnCloseRequest(new EventHandler<WindowEvent>() {
51-
@Override
52-
public void handle(WindowEvent event) {
53-
FxLayoutFrame.this.cleanup();
54-
}
55-
});
51+
// FxLayoutFrame.this.stage.setOnCloseRequest(event -> FxLayoutFrame.this.cleanup());
52+
5653
try {
5754
FxLayoutFrame.this.externalWindowObserver =
5855
new ExternalWindowObserver(desktopConnection.getPort(), appUuid, windowName, FxLayoutFrame.this.stage,

src/main/java/com/openfin/desktop/demo/LayoutFrame.java

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
import com.openfin.desktop.channel.ChannelClient;
1111
import com.openfin.desktop.win32.ExternalWindowObserver;
1212
import com.sun.jna.Native;
13-
import com.sun.jna.platform.win32.User32;
1413
import com.sun.jna.platform.win32.WinDef;
1514

1615
import org.json.JSONArray;
@@ -214,27 +213,14 @@ private void setHasFrame(JFrame frame, boolean hasFrame) {
214213
@Override
215214
public void run() {
216215
System.out.println(windowName + " hasFrame=" + hasFrame);
217-
218-
Dimension size = frame.getSize();
219216
WinDef.HWND hWnd = new WinDef.HWND();
220217
hWnd.setPointer(Native.getComponentPointer(frame));
221-
222-
int style = User32.INSTANCE.GetWindowLong(hWnd, User32.GWL_STYLE);
223-
224-
if (hasFrame) {
225-
frame.setResizable(true);
226-
// style = style & ~User32.WS_CHILD;
227-
style = style | User32.WS_CAPTION | User32.WS_BORDER | User32.WS_THICKFRAME;
228-
} else {
229-
frame.setResizable(false);
230-
style = style &~ User32.WS_CAPTION &~ User32.WS_BORDER &~ User32.WS_THICKFRAME;
231-
// style = style | User32.WS_CHILD;
232-
}
233-
User32.INSTANCE.SetWindowLong(hWnd, User32.GWL_STYLE, style);
234-
User32.INSTANCE.RedrawWindow(hWnd, null, null, new WinDef.DWORD((User32.RDW_FRAME | User32.RDW_INVALIDATE)));
235-
frame.setSize(size.width, size.height + 1);
218+
LayoutFrame.this.externalWindowObserver.setHasFrame(hWnd, hasFrame);
219+
frame.setResizable(hasFrame);
236220
frame.invalidate();
221+
frame.validate();
237222
frame.repaint();
223+
SwingUtilities.updateComponentTreeUI(frame);
238224
}
239225
});
240226
}

0 commit comments

Comments
 (0)