本文整理匯總了Java中javafx.scene.Parent.setCache方法的典型用法代碼示例。如果您正苦於以下問題:Java Parent.setCache方法的具體用法?Java Parent.setCache怎麽用?Java Parent.setCache使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javafx.scene.Parent
的用法示例。
在下文中一共展示了Parent.setCache方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: handleApplicationNotification
import javafx.scene.Parent; //導入方法依賴的package包/類
@Override public void handleApplicationNotification(PreloaderNotification info) {
if (info instanceof PreloaderHandoverEvent) {
// handover from preloader to application
final PreloaderHandoverEvent event = (PreloaderHandoverEvent)info;
final Parent appRoot = event.getRoot();
// remove race track
root.getChildren().remove(raceTrack);
// stop simulating progress
simulatorTimeline.stop();
// apply application stylsheet to scene
preloaderScene.getStylesheets().setAll(event.getCssUrl());
// enable caching for smooth fade
appRoot.setCache(true);
// make hide appRoot then add it to scene
appRoot.setTranslateY(preloaderScene.getHeight());
root.getChildren().add(1,appRoot);
// animate fade in app content
Timeline fadeOut = new Timeline();
fadeOut.getKeyFrames().addAll(
new KeyFrame(
Duration.millis(1000),
new KeyValue(appRoot.translateYProperty(), 0, Interpolator.EASE_OUT)
),
new KeyFrame(
Duration.millis(1500),
new EventHandler<ActionEvent>() {
@Override public void handle(ActionEvent t) {
// turn off cache as not need any more
appRoot.setCache(false);
// done animation so start loading data
for (Runnable task: event.getDataLoadingTasks()) {
Platform.runLater(task);
}
}
}
)
);
fadeOut.play();
}
}
示例2: updateContentPanel
import javafx.scene.Parent; //導入方法依賴的package包/類
/**
* Updates content on right panel by loading tasks and changing
* the title.
* TODO: Improve loading performance.
*/
private void updateContentPanel() {
if (currentTaskList != null) {
titleTaskList.setText(currentTaskList.getName());
ArrayList<Task> alTasks = currentTaskList.getTskList();
tasksAnchorPane.getChildren().clear();
double distance = 10;
for (Task t : alTasks) {
try {
FXMLLoader fxmlLoader = new FXMLLoader(getClass()
.getResource("/FXML/task.fxml"));
Parent tc = (Parent) fxmlLoader.load();
//Alignements
AnchorPane.setLeftAnchor(tc, 10.0);
AnchorPane.setRightAnchor(tc, 10.0);
AnchorPane.setTopAnchor(tc, distance);
//Set task
TaskComponentController controller
= fxmlLoader.getController();
controller.setTask(t);
controller.setMainController(this);
controller.addEvents();
//Saves performance
tc.setCache(true);
tasksAnchorPane.getChildren().add(tc);
distance += DISTANCE_BETWEEN_TASKS;
} catch (IOException ex) {
Logger.getLogger(MainController.class.getName()).
log(Level.SEVERE, null, ex);
}
}
} else {
titleTaskList.setText("Blank");
}
}