當前位置: 首頁>>代碼示例>>Java>>正文


Java Service.setOnSucceeded方法代碼示例

本文整理匯總了Java中javafx.concurrent.Service.setOnSucceeded方法的典型用法代碼示例。如果您正苦於以下問題:Java Service.setOnSucceeded方法的具體用法?Java Service.setOnSucceeded怎麽用?Java Service.setOnSucceeded使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javafx.concurrent.Service的用法示例。


在下文中一共展示了Service.setOnSucceeded方法的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: loadFontWeights

import javafx.concurrent.Service; //導入方法依賴的package包/類
/**
 * @작성자 : KYJ
 * @작성일 : 2016. 12. 2.
 */
private void loadFontWeights() {

	Service<List<String>> createFxService = new Service<List<String>>() {
		@Override
		protected Task<List<String>> createTask() {
			return new Task<List<String>>() {
				@Override
				protected List<String> call() throws Exception {
					return FxUtil.FONTUtil.getFontWeights();
				}
			};
		}
	};

	createFxService.setOnSucceeded(w -> {
		List<String> value = createFxService.getValue();
		cbFontWeight.getItems().addAll(value);
	});

	createFxService.start();

}
 
開發者ID:callakrsos,項目名稱:Gargoyle,代碼行數:27,代碼來源:FontViewComposite.java

示例2: loadFontStyles

import javafx.concurrent.Service; //導入方法依賴的package包/類
private void loadFontStyles() {
	Service<List<String>> createFxService = new Service<List<String>>() {
		@Override
		protected Task<List<String>> createTask() {
			return new Task<List<String>>() {
				@Override
				protected List<String> call() throws Exception {
					return FxUtil.FONTUtil.getFontStyles();
				}
			};
		}
	};

	createFxService.setOnSucceeded(w -> {
		List<String> value = createFxService.getValue();
		cbFontStyles.getItems().addAll(value);
	});
	
	

	createFxService.start();

}
 
開發者ID:callakrsos,項目名稱:Gargoyle,代碼行數:24,代碼來源:FontViewComposite.java

示例3: handleDownloadButtonAction

import javafx.concurrent.Service; //導入方法依賴的package包/類
@FXML private void handleDownloadButtonAction(ActionEvent event){
    if(! MainApp.getZdsutils().isAuthenticated()){
        Service<Void> loginTask = handleLoginButtonAction(event);
        loginTask.setOnSucceeded(t -> downloadContents(null));
        loginTask.setOnCancelled(t -> {
            hBottomBox.getChildren().clear();
            Alert alert = new CustomAlert(AlertType.ERROR);
            alert.setTitle(Configuration.getBundle().getString("ui.dialog.auth.failed.title"));
            alert.setHeaderText(Configuration.getBundle().getString("ui.dialog.auth.failed.header"));
            alert.setContentText(Configuration.getBundle().getString("ui.dialog.auth.failed.text"));

            alert.showAndWait();
        });

        loginTask.start();
    }else{
        downloadContents(null);
    }
}
 
開發者ID:firm1,項目名稱:zest-writer,代碼行數:20,代碼來源:MenuController.java

示例4: handleDownloadArticleButtonAction

import javafx.concurrent.Service; //導入方法依賴的package包/類
@FXML private void handleDownloadArticleButtonAction(ActionEvent event){
    if(! MainApp.getZdsutils().isAuthenticated()){
        Service<Void> loginTask = handleLoginButtonAction(event);
        loginTask.setOnSucceeded(t -> downloadContents("ARTICLE"));
        loginTask.setOnCancelled(t -> {
            hBottomBox.getChildren().clear();
            Alert alert = new CustomAlert(AlertType.ERROR);
            alert.setTitle(Configuration.getBundle().getString("ui.dialog.auth.failed.title"));
            alert.setHeaderText(Configuration.getBundle().getString("ui.dialog.auth.failed.header"));
            alert.setContentText(Configuration.getBundle().getString("ui.dialog.auth.failed.text"));

            alert.showAndWait();
        });

        loginTask.start();
    }else{
        downloadContents("ARTICLE");
    }
}
 
開發者ID:firm1,項目名稱:zest-writer,代碼行數:20,代碼來源:MenuController.java

示例5: handleDownloadTutorialButtonAction

import javafx.concurrent.Service; //導入方法依賴的package包/類
@FXML private void handleDownloadTutorialButtonAction(ActionEvent event){
    if(! MainApp.getZdsutils().isAuthenticated()){
        Service<Void> loginTask = handleLoginButtonAction(event);
        loginTask.setOnSucceeded(t -> downloadContents("TUTORIAL"));
        loginTask.setOnCancelled(t -> {
            hBottomBox.getChildren().clear();
            Alert alert = new CustomAlert(AlertType.ERROR);
            alert.setTitle(Configuration.getBundle().getString("ui.dialog.auth.failed.title"));
            alert.setHeaderText(Configuration.getBundle().getString("ui.dialog.auth.failed.header"));
            alert.setContentText(Configuration.getBundle().getString("ui.dialog.auth.failed.text"));

            alert.showAndWait();
        });

        loginTask.start();
    }else{
        downloadContents("TUTORIAL");
    }
}
 
開發者ID:firm1,項目名稱:zest-writer,代碼行數:20,代碼來源:MenuController.java

示例6: handleDownloadOpinionButtonAction

import javafx.concurrent.Service; //導入方法依賴的package包/類
@FXML private void handleDownloadOpinionButtonAction(ActionEvent event){
    if(! MainApp.getZdsutils().isAuthenticated()){
        Service<Void> loginTask = handleLoginButtonAction(event);
        loginTask.setOnSucceeded(t -> downloadContents("OPINION"));
        loginTask.setOnCancelled(t -> {
            hBottomBox.getChildren().clear();
            Alert alert = new CustomAlert(AlertType.ERROR);
            alert.setTitle(Configuration.getBundle().getString("ui.dialog.auth.failed.title"));
            alert.setHeaderText(Configuration.getBundle().getString("ui.dialog.auth.failed.header"));
            alert.setContentText(Configuration.getBundle().getString("ui.dialog.auth.failed.text"));

            alert.showAndWait();
        });

        loginTask.start();
    }else{
        downloadContents("OPINION");
    }
}
 
開發者ID:firm1,項目名稱:zest-writer,代碼行數:20,代碼來源:MenuController.java

示例7: handleUploadButtonAction

import javafx.concurrent.Service; //導入方法依賴的package包/類
@FXML private void handleUploadButtonAction(ActionEvent event){
    if(! MainApp.getZdsutils().isAuthenticated()){
        Service<Void> loginTask = handleLoginButtonAction(event);
        loginTask.setOnCancelled(t -> {
            hBottomBox.getChildren().clear();
            Alert alert = new CustomAlert(AlertType.ERROR);
            alert.setTitle(Configuration.getBundle().getString("ui.dialog.upload.content.failed.title"));
            alert.setHeaderText(Configuration.getBundle().getString("ui.dialog.upload.content.failed.header"));
            alert.setContentText(Configuration.getBundle().getString("ui.dialog.upload.content.failed.text"));

            alert.showAndWait();
        });
        loginTask.setOnSucceeded(t -> uploadContents());
        loginTask.start();
    }else{
        uploadContents();
    }
}
 
開發者ID:firm1,項目名稱:zest-writer,代碼行數:19,代碼來源:MenuController.java

示例8: handleSelectFileAction

import javafx.concurrent.Service; //導入方法依賴的package包/類
@FXML private void handleSelectFileAction(){
    if(! zdsUtils.isAuthenticated()){
        Service<Void> loginTask = menuManager.handleLoginButtonAction(null);
        loginTask.setOnSucceeded(t -> selectAndUploadImage());
        loginTask.setOnCancelled(t -> {
            menuManager.getHBottomBox().getChildren().clear();
            Alert alert = new CustomAlert(AlertType.ERROR);
            alert.setTitle(Configuration.getBundle().getString("ui.dialog.auth.failed.title"));
            alert.setHeaderText(Configuration.getBundle().getString("ui.dialog.auth.failed.header"));
            alert.setContentText(Configuration.getBundle().getString("ui.dialog.auth.failed.text"));

            alert.showAndWait();
        });
        loginTask.start();
    }else{
        selectAndUploadImage();
    }
}
 
開發者ID:firm1,項目名稱:zest-writer,代碼行數:19,代碼來源:ImageInputDialog.java

示例9: loadFontNames

import javafx.concurrent.Service; //導入方法依賴的package包/類
/**
 * 폰트명 로딩
 * @작성자 : KYJ
 * @작성일 : 2016. 12. 2.
 */
private void loadFontNames() {

	Service<List<String>> createFxService = new Service<List<String>>() {
		@Override
		protected Task<List<String>> createTask() {
			return new Task<List<String>>() {
				@Override
				protected List<String> call() throws Exception {
					List<String> avaliableFontNames = FxUtil.FONTUtil.getAvaliableFontNames();
					return avaliableFontNames;
				}
			};
		}
	};

	createFxService.setOnSucceeded(w -> {
		List<String> value = createFxService.getValue();
		cbFontNames.getItems().addAll(value);
		LOGGER.debug("Font Load Completed.");

		cbFontNames.setDisable(false);
	});
	
	createFxService.setExecutor(newFixedThreadExecutor);
	createFxService.start();

}
 
開發者ID:callakrsos,項目名稱:Gargoyle,代碼行數:33,代碼來源:FontViewComposite.java

示例10: handleImport

import javafx.concurrent.Service; //導入方法依賴的package包/類
@FXML
private void handleImport(ActionEvent event) {
    final Service<Attachments> service = importersBox.getValue();
    if (service.isRunning()) {
        service.cancel();
        return;
    }
    service.reset();

    importersBox.disableProperty().bind(service.runningProperty());
    progressBar.visibleProperty().bind(service.runningProperty());
    progressBar.progressProperty().bind(service.progressProperty());
    service.runningProperty().addListener(e -> {
        final String key = service.isRunning() ? "cancel" : "import";
        importButton.setText(resources.getString(key));
    });
    service.setOnFailed(e -> Notification.error(resources.getString("notification.failed")));
    service.setOnSucceeded(e -> {
        Notification.success(resources.getString("notification.completed"));

        final Attachments attachments = service.getValue();
        if (attachments == null) return;

        NoticeController.getNoticeTreeViewController().getCurrentNotice().addAttachments(attachments);
        NoticeController.getNoticeViewController().rebuildAttachsView();
    });
    service.start();
}
 
開發者ID:NoticEditorTeam,項目名稱:NoticEditor,代碼行數:29,代碼來源:AttachmentImportController.java

示例11: registerListeners

import javafx.concurrent.Service; //導入方法依賴的package包/類
/**
 * Registers a listener on the service to update the completableFuture.
 * @param service The service.
 * @param completableFuture	The future.
 * @param <T> The expected type.
 */
public static <T> void registerListeners(Service<T> service,
		CompletableFuture<T> completableFuture) {
	service.setOnSucceeded(e -> completableFuture.complete(service.getValue()));
	service.setOnFailed(e ->
		completableFuture.completeExceptionally(service.getException()));
	service.setOnCancelled(e -> completableFuture.cancel(true));
}
 
開發者ID:ProgrammingLife2015,項目名稱:dnainator,代碼行數:14,代碼來源:LoadServiceTestUtils.java

示例12: handleAction

import javafx.concurrent.Service; //導入方法依賴的package包/類
private void handleAction(ActionEvent ae) {

		// retrieving bean properties may take some time
		// so we have to put it on separate thread to keep UI responsive
		Service<?> service = new Service<ObservableList<Item>>() {

			@Override
			protected Task<ObservableList<Item>> createTask() {
				return new Task<ObservableList<Item>>() {
					@Override
					protected ObservableList<Item> call() throws Exception {
						return bean == null ? null : getProperties(bean);
					}
				};
			}

		};
		service.setOnSucceeded(new EventHandler<WorkerStateEvent>() {

			@SuppressWarnings("unchecked")
			@Override
			public void handle(WorkerStateEvent e) {
				ObservableList<Item> items = (ObservableList<Item>) e.getSource().getValue();
				if (items != null) {
					try {
						propertySheet.getItems().setAll(items.filtered((v) -> v != null));
					} catch (Exception exc) {
						//exc.printStackTrace();
						propertySheet.getItems().clear();
					}
				} else {
					propertySheet.getItems().clear();
				}
			}
		});
		service.start();

	}
 
開發者ID:davidB,項目名稱:jme3_ext_spatial_explorer,代碼行數:39,代碼來源:Explorer0.java

示例13: start

import javafx.concurrent.Service; //導入方法依賴的package包/類
@Override
    public void start(Stage primaryStage) {
        
//        try {
            BorderPane borderPane = new BorderPane();
            Scene scene = new Scene(borderPane, 800, 600);
            StopList.add(hashtag);
            
            /* TWITTER */
//        log=CLogOut.getInstance();
//        log.getMessages().addListener((ov,s,s1)->System.out.println(s1));
            
            final Service service=new Service<Void>(){
                @Override protected Task<Void> createTask() {   
                    Task<Void> task = new Task<Void>(){
                        @Override protected Void call() throws Exception {
                            final List<String> rawParameters = getParameters().getRaw();
                            conf = TwitterOAuth.getInstance(rawParameters.toArray(new String[rawParameters.size()])).readOAuth();
                            return null;
                        }
                    };
                    return task;
                }
            };
            
            service.setOnSucceeded(e->{
                if(!hashtag.isEmpty() && conf!=null){
                    tweetsTask= new TagTweets(conf, hashtag, borderPane);
                    tweetsTask.start();
                }
            });
            
            primaryStage.setTitle("The JavaFX Tweetwall for NetBeans Day!");
//            primaryStage.setTitle("The JavaFX Tweetwall for Devoxx!");
            primaryStage.setScene(scene);
            primaryStage.show();
            primaryStage.setFullScreen(true);
            service.start();
//        } catch (IOException ex) {
//            Logger.getLogger(TagCloud.class.getName()).log(Level.SEVERE, null, ex);
//        }
    }
 
開發者ID:svenreimers,項目名稱:TweetwallFX-Legacy,代碼行數:43,代碼來源:TagCloud.java


注:本文中的javafx.concurrent.Service.setOnSucceeded方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。