当前位置: 首页>>代码示例>>Java>>正文


Java WebEvent类代码示例

本文整理汇总了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);
                }
            }
        }
    };
}
 
开发者ID:mobilesystems,项目名称:box-java-sdk-v2,代码行数:18,代码来源:JavaFxOAuthFlow.java

示例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);
}
 
开发者ID:mars-sim,项目名称:mars-sim,代码行数:22,代码来源:DatePicker.java

示例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();
    
}
 
开发者ID:rterp,项目名称:GMapsFX,代码行数:19,代码来源:MainApp2.java

示例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);
}
 
开发者ID:SaiPradeepDandem,项目名称:javafx-demos,代码行数:22,代码来源:DatePicker.java

示例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);
}
 
开发者ID:SaiPradeepDandem,项目名称:javafx-demos,代码行数:22,代码来源:DatePicker.java

示例6: AlertEventHandlerWrapper

import javafx.scene.web.WebEvent; //导入依赖的package包/类
private AlertEventHandlerWrapper(
        WebEngine engine,
        EventHandler<WebEvent<String>> wrappedHandler) {

    this.engine = engine;
    this.wrappedHandler = wrappedHandler;
}
 
开发者ID:jamf,项目名称:HealthCheckUtility,代码行数:8,代码来源:JavaToJavascriptBridge.java

示例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);
}
 
开发者ID:jamf,项目名称:HealthCheckUtility,代码行数:11,代码来源:JavaToJavascriptBridge.java

示例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.
    };
}
 
开发者ID:proofy,项目名称:willow-browser,代码行数:15,代码来源:DialogFactory.java

示例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");
        }
    }
}
 
开发者ID:travelimg,项目名称:travelimg,代码行数:40,代码来源:GoogleMapScene.java

示例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 ) );
							}
						}

					}
			);
		}
	} );
}
 
开发者ID:Ostrich-Emulators,项目名称:semtool,代码行数:37,代码来源:BrowserPlaySheet2.java

示例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();
}
 
开发者ID:lipido,项目名称:javafxwebview,代码行数:35,代码来源:WebViewDemo.java

示例12: AlertEventHandlerWrapper

import javafx.scene.web.WebEvent; //导入依赖的package包/类
private AlertEventHandlerWrapper(
		WebEngine engine, 
		EventHandler<WebEvent<String>> wrappedHandler) {
	
	this.engine = engine;
	this.wrappedHandler = wrappedHandler;
}
 
开发者ID:lipido,项目名称:javafxwebview,代码行数:8,代码来源:Java2JavascriptUtils.java

示例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);
}
 
开发者ID:lipido,项目名称:javafxwebview,代码行数:11,代码来源:Java2JavascriptUtils.java

示例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);
}
 
开发者ID:dennisfischer,项目名称:simplejavayoutubeuploader,代码行数:13,代码来源:TagTextArea.java

示例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);
                }
            });
        }
    };
}
 
开发者ID:seraphy,项目名称:EmbeddedTomcatLauncher,代码行数:20,代码来源:EmbeddedServerBrowserFrame.java


注:本文中的javafx.scene.web.WebEvent类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。