From 0a0f829c49d720a54acc9d4c74e311aca3ed19d3 Mon Sep 17 00:00:00 2001 From: vito Date: Wed, 6 Apr 2016 09:47:24 +0800 Subject: [PATCH 1/5] =?UTF-8?q?=E5=92=A8=E8=AF=A2=E7=AA=97=E4=BD=93?= =?UTF-8?q?=E5=8E=BB=E6=8E=89=E8=BE=B9=E6=A1=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- designer/src/com/fr/design/mainframe/bbs/BBSDialog.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/designer/src/com/fr/design/mainframe/bbs/BBSDialog.java b/designer/src/com/fr/design/mainframe/bbs/BBSDialog.java index 3465d1793..52cd59165 100644 --- a/designer/src/com/fr/design/mainframe/bbs/BBSDialog.java +++ b/designer/src/com/fr/design/mainframe/bbs/BBSDialog.java @@ -39,7 +39,7 @@ public class BBSDialog extends UIDialog { public BBSDialog(Frame parent) { super(parent); - //setUndecorated(true); + setUndecorated(true); JPanel panel = (JPanel) getContentPane(); initComponents(panel); setSize(new Dimension(OUTER_WIDTH, OUTER_HEIGHT)); From b39cc4dd83df49f833a7b6387aad09aced975ab5 Mon Sep 17 00:00:00 2001 From: vito Date: Tue, 12 Apr 2016 18:58:41 +0800 Subject: [PATCH 2/5] =?UTF-8?q?=E5=92=A8=E8=AF=A2=E6=A1=86=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fr/design/mainframe/bbs/BBSDialog.java | 6 ++- .../fr/design/mainframe/bbs/BBSWebBridge.java | 51 +++++++++++++++++++ 2 files changed, 56 insertions(+), 1 deletion(-) create mode 100644 designer/src/com/fr/design/mainframe/bbs/BBSWebBridge.java diff --git a/designer/src/com/fr/design/mainframe/bbs/BBSDialog.java b/designer/src/com/fr/design/mainframe/bbs/BBSDialog.java index 52cd59165..480fec939 100644 --- a/designer/src/com/fr/design/mainframe/bbs/BBSDialog.java +++ b/designer/src/com/fr/design/mainframe/bbs/BBSDialog.java @@ -14,6 +14,7 @@ import javafx.scene.Group; import javafx.scene.Scene; import javafx.scene.web.WebEngine; import javafx.scene.web.WebView; +import netscape.javascript.JSObject; import javax.swing.*; @@ -43,6 +44,7 @@ public class BBSDialog extends UIDialog { JPanel panel = (JPanel) getContentPane(); initComponents(panel); setSize(new Dimension(OUTER_WIDTH, OUTER_HEIGHT)); + BBSWebBridge.getHelper().setDialogHandle(this); } private void initComponents(JPanel contentPane) { @@ -58,6 +60,8 @@ public class BBSDialog extends UIDialog { Platform.runLater(new Runnable() { @Override public void run() { + JSObject obj = (JSObject) eng.executeScript("window"); + obj.setMember("BBSWebBridge", BBSWebBridge.getHelper(eng)); eng.executeScript("history.go(0)"); } }); @@ -112,7 +116,7 @@ public class BBSDialog extends UIDialog { } }); } - + // 在本地浏览器里打开url private void openUrlAtLocalWebBrowser(WebEngine eng,String url){ if(Desktop.isDesktopSupported()){ diff --git a/designer/src/com/fr/design/mainframe/bbs/BBSWebBridge.java b/designer/src/com/fr/design/mainframe/bbs/BBSWebBridge.java new file mode 100644 index 000000000..283a12d6a --- /dev/null +++ b/designer/src/com/fr/design/mainframe/bbs/BBSWebBridge.java @@ -0,0 +1,51 @@ +package com.fr.design.mainframe.bbs; + +import com.fr.design.dialog.UIDialog; +import javafx.scene.web.WebEngine; + +import javax.swing.*; + +/** + * Created by vito on 16/4/12. + */ +public class BBSWebBridge { + private static BBSWebBridge bbsWebBridge; + private WebEngine webEngine; + private UIDialog uiDialog; + + public static BBSWebBridge getHelper() { + if (bbsWebBridge != null) { + return bbsWebBridge; + } + synchronized (BBSWebBridge.class) { + if (bbsWebBridge == null) { + bbsWebBridge = new BBSWebBridge(); + } + return bbsWebBridge; + } + } + + public static BBSWebBridge getHelper(WebEngine webEngine) { + getHelper(); + bbsWebBridge.setEngine(webEngine); + return bbsWebBridge; + } + + private void setEngine(WebEngine webEngine) { + this.webEngine = webEngine; + } + + private BBSWebBridge() {} + + public void closeWindow() { + if (uiDialog != null) { + uiDialog.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE); + uiDialog.setVisible(false); + uiDialog.dispose(); + } + } + + public void setDialogHandle(UIDialog uiDialog){ + this.uiDialog = uiDialog; + } +} From 776116ee0140591bdef8456d65509e18c6d6991d Mon Sep 17 00:00:00 2001 From: vito Date: Wed, 13 Apr 2016 00:18:32 +0800 Subject: [PATCH 3/5] =?UTF-8?q?web=E7=AB=AF=E7=9A=84=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E4=B8=8D=E7=8B=AC=E7=AB=8B=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fr/design/mainframe/bbs/BBSDialog.java | 13 +++-- .../fr/design/mainframe/bbs/BBSWebBridge.java | 51 ------------------- 2 files changed, 10 insertions(+), 54 deletions(-) delete mode 100644 designer/src/com/fr/design/mainframe/bbs/BBSWebBridge.java diff --git a/designer/src/com/fr/design/mainframe/bbs/BBSDialog.java b/designer/src/com/fr/design/mainframe/bbs/BBSDialog.java index 480fec939..99ba8c28f 100644 --- a/designer/src/com/fr/design/mainframe/bbs/BBSDialog.java +++ b/designer/src/com/fr/design/mainframe/bbs/BBSDialog.java @@ -37,6 +37,8 @@ public class BBSDialog extends UIDialog { private JFXPanel jfxPanel; + private BBSDialog that;//保存一个引用给问页面调用 + public BBSDialog(Frame parent) { super(parent); @@ -44,7 +46,7 @@ public class BBSDialog extends UIDialog { JPanel panel = (JPanel) getContentPane(); initComponents(panel); setSize(new Dimension(OUTER_WIDTH, OUTER_HEIGHT)); - BBSWebBridge.getHelper().setDialogHandle(this); + that = this; } private void initComponents(JPanel contentPane) { @@ -60,8 +62,6 @@ public class BBSDialog extends UIDialog { Platform.runLater(new Runnable() { @Override public void run() { - JSObject obj = (JSObject) eng.executeScript("window"); - obj.setMember("BBSWebBridge", BBSWebBridge.getHelper(eng)); eng.executeScript("history.go(0)"); } }); @@ -89,6 +89,8 @@ public class BBSDialog extends UIDialog { view.setMinSize(widthDouble, heightDouble); view.setPrefSize(widthDouble, heightDouble); final WebEngine eng = view.getEngine(); + JSObject obj = (JSObject) eng.executeScript("window"); + obj.setMember("BBSWebBridge", that);//一定要在load页面之前加载接口 //webEngine的userAgent貌似支持移动设备的,任何其他浏览器的userAngent都会导致程序崩溃 //eng.setUserAgent("Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_2) Apple/WebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.76 Safari/537.36"); eng.load(url); @@ -140,6 +142,11 @@ public class BBSDialog extends UIDialog { } } + public void closeWindow() { + this.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE); + this.setVisible(false); + this.dispose(); + } /** * 略 */ diff --git a/designer/src/com/fr/design/mainframe/bbs/BBSWebBridge.java b/designer/src/com/fr/design/mainframe/bbs/BBSWebBridge.java deleted file mode 100644 index 283a12d6a..000000000 --- a/designer/src/com/fr/design/mainframe/bbs/BBSWebBridge.java +++ /dev/null @@ -1,51 +0,0 @@ -package com.fr.design.mainframe.bbs; - -import com.fr.design.dialog.UIDialog; -import javafx.scene.web.WebEngine; - -import javax.swing.*; - -/** - * Created by vito on 16/4/12. - */ -public class BBSWebBridge { - private static BBSWebBridge bbsWebBridge; - private WebEngine webEngine; - private UIDialog uiDialog; - - public static BBSWebBridge getHelper() { - if (bbsWebBridge != null) { - return bbsWebBridge; - } - synchronized (BBSWebBridge.class) { - if (bbsWebBridge == null) { - bbsWebBridge = new BBSWebBridge(); - } - return bbsWebBridge; - } - } - - public static BBSWebBridge getHelper(WebEngine webEngine) { - getHelper(); - bbsWebBridge.setEngine(webEngine); - return bbsWebBridge; - } - - private void setEngine(WebEngine webEngine) { - this.webEngine = webEngine; - } - - private BBSWebBridge() {} - - public void closeWindow() { - if (uiDialog != null) { - uiDialog.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE); - uiDialog.setVisible(false); - uiDialog.dispose(); - } - } - - public void setDialogHandle(UIDialog uiDialog){ - this.uiDialog = uiDialog; - } -} From 54961579ec33458bfc022a67996d319cc1112a8c Mon Sep 17 00:00:00 2001 From: vito Date: Wed, 13 Apr 2016 00:22:04 +0800 Subject: [PATCH 4/5] =?UTF-8?q?=E6=B3=A8=E9=87=8A=E6=BC=8F=E4=BC=A0?= =?UTF-8?q?=E4=BA=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- designer/src/com/fr/design/mainframe/bbs/BBSDialog.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/designer/src/com/fr/design/mainframe/bbs/BBSDialog.java b/designer/src/com/fr/design/mainframe/bbs/BBSDialog.java index 99ba8c28f..40619ef75 100644 --- a/designer/src/com/fr/design/mainframe/bbs/BBSDialog.java +++ b/designer/src/com/fr/design/mainframe/bbs/BBSDialog.java @@ -142,6 +142,9 @@ public class BBSDialog extends UIDialog { } } + /** + * 提供给web页面调用的关闭窗口 + */ public void closeWindow() { this.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE); this.setVisible(false); From efb1cfb769a6b12a3272902d3f01026e078e3a01 Mon Sep 17 00:00:00 2001 From: vito Date: Wed, 13 Apr 2016 09:30:33 +0800 Subject: [PATCH 5/5] BBSDialog.this --- designer/src/com/fr/design/mainframe/bbs/BBSDialog.java | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/designer/src/com/fr/design/mainframe/bbs/BBSDialog.java b/designer/src/com/fr/design/mainframe/bbs/BBSDialog.java index 40619ef75..0ee433bd1 100644 --- a/designer/src/com/fr/design/mainframe/bbs/BBSDialog.java +++ b/designer/src/com/fr/design/mainframe/bbs/BBSDialog.java @@ -37,8 +37,6 @@ public class BBSDialog extends UIDialog { private JFXPanel jfxPanel; - private BBSDialog that;//保存一个引用给问页面调用 - public BBSDialog(Frame parent) { super(parent); @@ -46,7 +44,6 @@ public class BBSDialog extends UIDialog { JPanel panel = (JPanel) getContentPane(); initComponents(panel); setSize(new Dimension(OUTER_WIDTH, OUTER_HEIGHT)); - that = this; } private void initComponents(JPanel contentPane) { @@ -90,7 +87,7 @@ public class BBSDialog extends UIDialog { view.setPrefSize(widthDouble, heightDouble); final WebEngine eng = view.getEngine(); JSObject obj = (JSObject) eng.executeScript("window"); - obj.setMember("BBSWebBridge", that);//一定要在load页面之前加载接口 + obj.setMember("BBSWebBridge", BBSDialog.this);//一定要在load页面之前加载接口 //webEngine的userAgent貌似支持移动设备的,任何其他浏览器的userAngent都会导致程序崩溃 //eng.setUserAgent("Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_2) Apple/WebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.76 Safari/537.36"); eng.load(url);