Skip to content

Commit 0168b87

Browse files
authored
Merge pull request #24 from WanneSimon/main
example: fixed size in fx
2 parents 6e64dba + bbd18f3 commit 0168b87

1 file changed

Lines changed: 9 additions & 8 deletions

File tree

  • examples/src/main/java/dev/webview/webview_java/example/fx

examples/src/main/java/dev/webview/webview_java/example/fx/FxExample.java

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,12 @@ public static void main(String[] args) {
2626
public void start(Stage stage) throws Exception {
2727
root = new StackPane();
2828

29-
Scene s = new Scene(root, 400,300);
29+
Scene s = new Scene(root, 800,600);
3030
stage.setScene(s);
3131
stage.setTitle("TestWindow");
3232

3333
stage.show();
3434
this.stage = stage;
35-
stage.setResizable(false); // not allow to resize
3635

3736
this.initWv();
3837
}
@@ -43,16 +42,18 @@ private void initWv() throws InvocationTargetException, NoSuchMethodException, I
4342
wv = new Webview(true, new PointerByReference(FXStageDetect.getWindowPointer(stage)),
4443
(int)s.getWidth(), (int)s.getHeight());
4544
wv.setTitle("TestWindow");
45+
// note: not allow to resize
46+
wv.setFixedSize((int)s.getWidth(), (int)s.getHeight());
4647

4748
bindJs();
4849

4950
// bind resize (not working)
50-
s.widthProperty().addListener((observable, oldValue, newValue) -> {
51-
wv.setSize(newValue.intValue(), (int)s.getHeight());
52-
});
53-
s.heightProperty().addListener((observable, oldValue, newValue) -> {
54-
wv.setSize((int)s.getWidth(), newValue.intValue());
55-
});
51+
//s.widthProperty().addListener((observable, oldValue, newValue) -> {
52+
// wv.setSize(newValue.intValue(), (int)s.getHeight());
53+
//});
54+
//s.heightProperty().addListener((observable, oldValue, newValue) -> {
55+
// wv.setSize((int)s.getWidth(), newValue.intValue());
56+
//});
5657

5758
// 关闭
5859
stage.setOnCloseRequest(e -> {

0 commit comments

Comments
 (0)