Browse Source

咨询框接口

master
vito 9 years ago
parent
commit
b39cc4dd83
  1. 4
      designer/src/com/fr/design/mainframe/bbs/BBSDialog.java
  2. 51
      designer/src/com/fr/design/mainframe/bbs/BBSWebBridge.java

4
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)");
}
});

51
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;
}
}
Loading…
Cancel
Save