本文整理汇总了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");
}
}