本文整理汇总了Java中javafx.scene.web.WebEvent类的典型用法代码示例。如果您正苦于以下问题:Java WebEvent类的具体用法?Java WebEvent怎么用?Java WebEvent使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
WebEvent类属于javafx.scene.web包,在下文中一共展示了WebEvent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createEventHandler
import javafx.scene.web.WebEvent; //导入依赖的package包/类
private EventHandler<WebEvent<String>> createEventHandler() {
return new EventHandler<WebEvent<String>>() {
@Override
public void handle(WebEvent<String> event) {
if (event.getSource() instanceof WebEngine) {
WebEngine engine = (WebEngine) event.getSource();
String url = engine.getLocation();
String code = getResponseValueFromUrl(url);
if (StringUtils.isNotEmpty(code)) {
webEngine.getLoadWorker().cancel();
startCreateOAuth(code);
}
}
}
};
}
示例2: initPicker
import javafx.scene.web.WebEvent; //导入依赖的package包/类
private void initPicker(WebView webView) {
// attach a handler for an alert function call which will set the DatePicker's date property.
webView.getEngine().setOnAlert(new EventHandler<WebEvent<String>>() {
@Override public void handle(WebEvent<String> event) {
try { date.set(jQueryUiDateFormat.parse(event.getData())); } catch (ParseException e) { /* no action required */ }
}
});
// place the webView holding the jQuery date picker inside this node.
this.getChildren().add(webView);
// monitor the date for changes and update the formatted date string to keep it in sync.
date.addListener(new ChangeListener<Date>() {
@Override public void changed(ObservableValue<? extends Date> observableValue, Date oldDate, Date newDate) {
dateString.set(dateFormat.format(newDate));
}
});
// workaround as I don't know how to size the stack to the size of the enclosed WebPane's html content.
this.setMaxSize(330, 280);//307, 241);
}
示例3: start
import javafx.scene.web.WebEvent; //导入依赖的package包/类
@Override
public void start(final Stage stage) throws Exception {
mapComponent = new GoogleMapView();
mapComponent.addMapInitializedListener(this);
mapComponent.setDisableDoubleClick(true);
mapComponent.getWebview().getEngine().setOnAlert((WebEvent<String> event) -> {
// System.out.println("Event event: " + event);
});
BorderPane bp = new BorderPane();
bp.setCenter(mapComponent);
Scene scene = new Scene(bp);
stage.setScene(scene);
stage.show();
}
示例4: initPicker
import javafx.scene.web.WebEvent; //导入依赖的package包/类
private void initPicker(WebView webView) {
// attach a handler for an alert function call which will set the DatePicker's date property.
webView.getEngine().setOnAlert(new EventHandler<WebEvent<String>>() {
@Override public void handle(WebEvent<String> event) {
try { date.set(jQueryUiDateFormat.parse(event.getData())); } catch (ParseException e) { /* no action required */ }
}
});
// place the webView holding the jQuery date picker inside this node.
this.getChildren().add(webView);
// monitor the date for changes and update the formatted date string to keep it in sync.
date.addListener(new ChangeListener<Date>() {
@Override public void changed(ObservableValue<? extends Date> observableValue, Date oldDate, Date newDate) {
dateString.set(dateFormat.format(newDate));
}
});
// workaround as I don't know how to size the stack to the size of the enclosed WebPane's html content.
this.setMaxSize(320, 250);
}
示例5: initPicker
import javafx.scene.web.WebEvent; //导入依赖的package包/类
private void initPicker(WebView webView) {
// attach a handler for an alert function call which will set the DatePicker's date property.
webView.getEngine().setOnAlert(new EventHandler<WebEvent<String>>() {
@Override public void handle(WebEvent<String> event) {
try { date.set(jQueryUiDateFormat.parse(event.getData())); } catch (ParseException e) { /* no action required */ }
}
});
// place the webView holding the jQuery date picker inside this node.
this.getChildren().add(webView);
// monitor the date for changes and update the formatted date string to keep it in sync.
date.addListener(new ChangeListener<Date>() {
@Override public void changed(ObservableValue<? extends Date> observableValue, Date oldDate, Date newDate) {
dateString.set(dateFormat.format(newDate));
}
});
// workaround as I don't know how to size the stack to the size of the enclosed WebPane's html content.
this.setMaxSize(307, 241);
}
示例6: AlertEventHandlerWrapper
import javafx.scene.web.WebEvent; //导入依赖的package包/类
private AlertEventHandlerWrapper(
WebEngine engine,
EventHandler<WebEvent<String>> wrappedHandler) {
this.engine = engine;
this.wrappedHandler = wrappedHandler;
}
示例7: handle
import javafx.scene.web.WebEvent; //导入依赖的package包/类
@Override
public void handle(WebEvent<String> arg0) {
if (arg0.getData().contains(CONNECT_BACKEND_MAGIC_WORD)) {
String varname = arg0.getData().substring(
CONNECT_BACKEND_MAGIC_WORD.length());
connectToWebEngine(engine, varname);
}
else if (wrappedHandler != null) wrappedHandler.handle(arg0);
}
示例8: createAlertHandler
import javafx.scene.web.WebEvent; //导入依赖的package包/类
public EventHandler<WebEvent<String>> createAlertHandler() {
return stringWebEvent -> {
AlertHandler alertHandler = new AlertHandler(
stringWebEvent.getData(),
event -> {
webView.setDisable(false);
removeViewOverlay();
}
);
overlayView(alertHandler);
// todo block until the user accepts the alert.
};
}
示例9: handleAlert
import javafx.scene.web.WebEvent; //导入依赖的package包/类
private void handleAlert(WebEvent<String> event) {
LOGGER.debug("Got alert {}", event);
String data = event.getData();
if (data.equals("map-loaded")) {
if (onLoadedCallback != null) {
onLoadedCallback.run();
}
} else if (data.contains("click")) {
String type = data.substring(0, data.indexOf("("));
String params = data.substring(data.indexOf("(") + 1, data.indexOf(")"));
String latLng[] = params.split(",");
if (latLng.length != 2) {
return;
}
try {
double latitude = Double.parseDouble(latLng[0].trim());
double longitude = Double.parseDouble(latLng[1].trim());
if (type.equals("double-click") && doubleClickCallback != null) {
doubleClickCallback.accept(new LatLong(latitude, longitude));
} else if (type.equals("click") && clickCallback != null) {
clickCallback.accept(new LatLong(latitude, longitude));
} else if (type.equals("marker-click") && markerClickCallback != null) {
markerClickCallback.accept(new LatLong(latitude,longitude));
}
} catch (NumberFormatException ex) {
LOGGER.debug("Failed to parse click event from map");
}
}
}
示例10: BrowserPlaySheet2
import javafx.scene.web.WebEvent; //导入依赖的package包/类
public BrowserPlaySheet2( String htmlPath ) {
setLayout( new BorderLayout() );
add( jfxPanel );
fileName = "file:///"
+ new File( DIHelper.getInstance().getLocalStore(), htmlPath );
Platform.setImplicitExit( false );
Platform.runLater( new Runnable() {
@Override
public void run() {
WebView view = new WebView();
scene = new Scene( view );
jfxPanel.setScene( scene );
engine = view.getEngine();
engine.setOnAlert(
new EventHandler<WebEvent<String>>() {
@Override
public void handle( WebEvent<String> event ) {
log.debug( "handling event: " + event );
if ( "document:loaded".equals( event.getData() ) ) {
log.debug( "Document is loaded." );
sendToWebView();
}
else if ( event.getData().startsWith( "download:csv" ) ) {
log.debug( "Downloading CSV file from browser." );
downloadCSV( event.getData().substring( 12 ) );
}
}
}
);
}
} );
}
示例11: createWebView
import javafx.scene.web.WebEvent; //导入依赖的package包/类
private void createWebView(Stage primaryStage, String page) {
// create the JavaFX webview
final WebView webView = new WebView();
// connect the FruitsService instance as "fruitsService"
// javascript variable
connectBackendObject(
webView.getEngine(),
"fruitsService", new FruitsService());
// connect the CalculatorService instance as "calculatorService"
// javascript variable
connectBackendObject(
webView.getEngine(),
"calculatorService", new CalculatorService());
// show "alert" Javascript messages in stdout (useful to debug)
webView.getEngine().setOnAlert(new EventHandler<WebEvent<String>>(){
@Override
public void handle(WebEvent<String> arg0) {
System.err.println("alertwb1: " + arg0.getData());
}
});
// load index.html
webView.getEngine().load(
getClass().getResource(page).
toExternalForm());
primaryStage.setScene(new Scene(webView));
primaryStage.setTitle("WebView with Java backend");
primaryStage.show();
}
示例12: AlertEventHandlerWrapper
import javafx.scene.web.WebEvent; //导入依赖的package包/类
private AlertEventHandlerWrapper(
WebEngine engine,
EventHandler<WebEvent<String>> wrappedHandler) {
this.engine = engine;
this.wrappedHandler = wrappedHandler;
}
示例13: handle
import javafx.scene.web.WebEvent; //导入依赖的package包/类
@Override
public void handle(WebEvent<String> arg0) {
if (arg0.getData().contains(CONNECT_BACKEND_MAGIC_WORD)) {
String varname = arg0.getData().substring(
CONNECT_BACKEND_MAGIC_WORD.length());
connectToWebEngine(engine, varname);
}
else if (wrappedHandler != null) wrappedHandler.handle(arg0);
}
示例14: initPicker
import javafx.scene.web.WebEvent; //导入依赖的package包/类
private void initPicker(final WebView webView) {
webView.getEngine().loadContent(getInlineHtml());
webView.setContextMenuEnabled(false);
webView.getEngine().setOnAlert(new EventHandler<WebEvent<String>>() {
@Override
public void handle(final WebEvent<String> event) {
tags.set(event.getData());
}
});
getChildren().add(webView);
}
示例15: createAlertHandler
import javafx.scene.web.WebEvent; //导入依赖的package包/类
/**
* JavaScriptのalert()のハンドラ.<br>
*
* @return
*/
private EventHandler<WebEvent<String>> createAlertHandler() {
return new EventHandler<WebEvent<String>>() {
@Override
public void handle(final WebEvent<String> stringWebEvent) {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
String message = stringWebEvent.getData();
JOptionPane.showMessageDialog(EmbeddedServerBrowserFrame.this, message);
}
});
}
};
}