本文整理匯總了Java中javafx.util.Duration.seconds方法的典型用法代碼示例。如果您正苦於以下問題:Java Duration.seconds方法的具體用法?Java Duration.seconds怎麽用?Java Duration.seconds使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javafx.util.Duration
的用法示例。
在下文中一共展示了Duration.seconds方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: Exe
import javafx.util.Duration; //導入方法依賴的package包/類
void Exe(int i) {
if(i==1) {
warnmesse="プレイ開始から5分経過しました\n混雑している場合は次の人に\n交代してください";
fontsize=25;
}else if(i==2) {
warnmesse="プレイ開始から10分経過しました\n混雑している場合は次の人に\n交代してください";
fontsize=25;
}else if(i==-1) {
warnmesse="user timer is reset";
fontsize=35;
}
final Stage primaryStage = new Stage(StageStyle.TRANSPARENT);
primaryStage.initModality(Modality.NONE);
final StackPane root = new StackPane();
final Scene scene = new Scene(root, 350, 140);
scene.setFill(null);
final Label label = new Label(warnmesse);
label.setFont(new Font("Arial", fontsize));
BorderPane borderPane = new BorderPane();
borderPane.setCenter(label);
borderPane.setStyle("-fx-background-radius: 10;-fx-background-color: rgba(0,0,0,0.3);");
root.getChildren().add(borderPane);
final Rectangle2D d = Screen.getPrimary().getVisualBounds();
primaryStage.setScene(scene);
primaryStage.setAlwaysOnTop(true);
primaryStage.setX(d.getWidth()-350);
primaryStage.setY(d.getHeight()-300);
primaryStage.show();
final Timeline timer = new Timeline(new KeyFrame(Duration.seconds(CLOSE_SECONDS), (ActionEvent event) -> primaryStage.close()));
timer.setCycleCount(Timeline.INDEFINITE);
timer.play();
}
示例2: keyPressedAnimation
import javafx.util.Duration; //導入方法依賴的package包/類
/**
* Animation for key pressed.
* @param b
*/
private void keyPressedAnimation(Button b) {
ScaleTransition st = new ScaleTransition(Duration.seconds(.2), b);
st.setFromX(.8);
st.setFromY(.8);
st.setToX(1.6);
st.setToY(1.6);
st.play();
st.setOnFinished(e -> {
if(!b.isHover()) {
ScaleTransition st2 = new ScaleTransition(Duration.seconds(.09), b);
st2.setToX(1);
st2.setToY(1);
st2.play();
}
});
FadeTransition ft = new FadeTransition(Duration.seconds(.2), b);
ft.setFromValue(.2);
ft.setToValue(1);
ft.play();
}
示例3: startAnimateForm300
import javafx.util.Duration; //導入方法依賴的package包/類
private Timeline startAnimateForm300() {
Timeline tml = new Timeline(
new KeyFrame(Duration.ZERO, new KeyValue(pnlContent.maxHeightProperty(), 70)),
new KeyFrame(Duration.seconds(0.4), new KeyValue(pnlContent.maxHeightProperty(), 300, Interpolator.EASE_BOTH)));
tml.setOnFinished((ActionEvent event) -> {
pnlForm.setVisible(true);
txtSend.requestFocus();
});
return tml;
}
示例4: rotateHer
import javafx.util.Duration; //導入方法依賴的package包/類
public void rotateHer(Label labelHer, ImageView iv)
{
RotateTransition rotation = new RotateTransition(Duration.seconds(2), iv);
rotation.setCycleCount(Animation.INDEFINITE);
rotation.setByAngle(360);
iv.setTranslateZ(iv.getBoundsInLocal().getWidth() / 2.0);
iv.setRotationAxis(Rotate.Y_AXIS);
labelHer.setOnMouseEntered(e ->
{
rotation.play();
iv.setRotate(180);
});
labelHer.setOnMouseExited(e ->
{
rotation.pause();
iv.setRotate(0);
});
}
示例5: periodicallyStrikeRandomNodes
import javafx.util.Duration; //導入方法依賴的package包/類
private void periodicallyStrikeRandomNodes(TilePane field) {
Timeline timeline = new Timeline(new KeyFrame(Duration.seconds(0), event -> strikeRandomNode(field)),
new KeyFrame(Duration.seconds(2)));
timeline.setCycleCount(Timeline.INDEFINITE);
timeline.play();
}
示例6: initializeTimeline
import javafx.util.Duration; //導入方法依賴的package包/類
private void initializeTimeline () {
Timeline timeline = getTimeline();
Duration frameDuration = Duration.seconds(1.0d / FPS);
KeyFrame repeatedFrame = new KeyFrame(frameDuration, e -> step(frameDuration));
timeline.getKeyFrames().add(repeatedFrame);
timeline.setCycleCount(Animation.INDEFINITE);
timeline.play();
}
示例7: configureBox
import javafx.util.Duration; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
private void configureBox(HBox root) {
StackPane container = new StackPane();
//container.setPrefHeight(700);
container.setPrefSize(boxBounds.getWidth(), boxBounds.getHeight());
container.setStyle("-fx-border-width:1px;-fx-border-style:solid;-fx-border-color:#999999;");
table= new TableView<AttClass>();
Label lview= new Label();
lview.setText("View Records");
lview.setId("lview");
bottomPane= new VBox();
tclock= new Text();
tclock.setId("lview");
//tclock.setFont(Font.font("Calibri", 20));
final Timeline timeline = new Timeline(new KeyFrame(Duration.seconds(1), new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
tclock.setText(DateFormat.getDateTimeInstance().format(new Date()));
}
}));
timeline.setCycleCount(Animation.INDEFINITE);
timeline.play();
bottomPane.getChildren().addAll(tclock,lview);
bottomPane.setAlignment(Pos.CENTER);
//table pane
namecol= new TableColumn<>("First Name");
namecol.setMinWidth(170);
namecol.setCellValueFactory(new PropertyValueFactory<>("name"));
admcol= new TableColumn<>("Identication No.");
admcol.setMinWidth(180);
admcol.setCellValueFactory(new PropertyValueFactory<>("adm"));
typecol= new TableColumn<>("Type");
typecol.setMinWidth(130);
typecol.setCellValueFactory(new PropertyValueFactory<>("type"));
timecol= new TableColumn<>("Signin");
timecol.setMinWidth(140);
timecol.setCellValueFactory(new PropertyValueFactory<>("timein"));
datecol= new TableColumn<>("Date");
datecol.setMinWidth(180);
datecol.setCellValueFactory(new PropertyValueFactory<>("date"));
table.getColumns().addAll(namecol, admcol, typecol, timecol, datecol);
table.setItems(getAtt());
att= getAtt();
table.setItems(FXCollections.observableArrayList(att));
table.setMinHeight(500);
btnrefresh = new Button("Refresh");
btnrefresh.setOnAction(new EventHandler<ActionEvent>() {
public void handle(ActionEvent t) {
table.setItems(getAtt());
}
});
laytable= new VBox(10);
laytable.getChildren().addAll(table, btnrefresh);
laytable.setAlignment(Pos.TOP_LEFT);
container.getChildren().addAll(bottomPane,laytable);
setAnimation();
sc.setContent(container);
root.setStyle("-fx-background-color: linear-gradient(#E4EAA2, #9CD672)");
root.getChildren().addAll(getActionPane(),sc);
//service.start();
}
示例8: showAllCurrentStatus
import javafx.util.Duration; //導入方法依賴的package包/類
private void showAllCurrentStatus() {
final Timeline status = new Timeline(
new KeyFrame(Duration.seconds(0),
new EventHandler<ActionEvent>() {
@Override public void handle(ActionEvent actionEvent) {
showBalanceStatus(currentBalanceStatus());
}
}
),
new KeyFrame(Duration.seconds(3))
);
status.setCycleCount(Animation.INDEFINITE);
status.play();
}
示例9: oakyButtonHandler
import javafx.util.Duration; //導入方法依賴的package包/類
public void oakyButtonHandler(MouseEvent event, Popup pp) {
ScaleTransition st = new ScaleTransition(Duration.seconds(.3), (Node) pp.getContent());
st.setToX(0);
st.play();
FadeTransition fd = new FadeTransition(Duration.seconds(.3), (Node) pp.getContent());
fd.setToValue(.2);
st.setOnFinished(e -> pp.hide());
}
示例10: buttonHovered
import javafx.util.Duration; //導入方法依賴的package包/類
/**
*
* @param b
*/
public void buttonHovered(Button b) {
ScaleTransition st = new ScaleTransition(Duration.seconds(.2), b);
st.setToX(1.6);
st.setToY(1.6);
st.play();
}
示例11: animateMovinement
import javafx.util.Duration; //導入方法依賴的package包/類
/**
*
* @param direction
* @param from
* @param to
*/
private synchronized void animateMovinement(Direction direction, Tile from, Tile to) {
TranslateTransition st = new TranslateTransition(Duration.seconds(.3), from);
st.setFromX(0);
st.setToX(direction.getX_location());
st.play();
st.setOnFinished(e -> {
to.combine(from);
this.checkCompletion(to);
from.remove();
});
}
示例12: AnimatedPopup
import javafx.util.Duration; //導入方法依賴的package包/類
private AnimatedPopup() {
showFadeTransition = new FadeTransition(Duration.seconds(0.2), getScene().getRoot());
showFadeTransition.setFromValue(0);
showFadeTransition.setToValue(1);
showFadeTransition.setInterpolator(new BackInterpolator());
showScaleTransition = new ScaleTransition(Duration.seconds(0.2), getScene().getRoot());
showScaleTransition.setFromX(0.8);
showScaleTransition.setFromY(0.8);
showScaleTransition.setToY(1);
showScaleTransition.setToX(1);
showScaleTransition.setInterpolator(new BackInterpolator());
hideFadeTransition = new FadeTransition(Duration.seconds(.3), getScene().getRoot());
hideFadeTransition.setFromValue(1);
hideFadeTransition.setToValue(0);
hideFadeTransition.setInterpolator(new BackInterpolator());
hideScaleTransition = new ScaleTransition(Duration.seconds(.3), getScene().getRoot());
hideScaleTransition.setFromX(1);
hideScaleTransition.setFromY(1);
hideScaleTransition.setToY(0.8);
hideScaleTransition.setToX(0.8);
hideScaleTransition.setInterpolator(new BackInterpolator());
hideScaleTransition.setOnFinished(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent actionEvent) {
if (AnimatedPopup.super.isShowing()) {
AnimatedPopup.super.hide();
}
}
});
}
示例13: popupCloser
import javafx.util.Duration; //導入方法依賴的package包/類
/**
*
* @param pp
*/
private void popupCloser(Popup pp, Node node) {
ScaleTransition st = new ScaleTransition(Duration.seconds(.3), node);
st.setToX(0);
st.setToY(0);
st.play();
FadeTransition fd = new FadeTransition(Duration.seconds(.3), node);
fd.setToValue(.2);
fd.play();
st.setOnFinished(e -> pp.hide());
}
示例14: createBlinker
import javafx.util.Duration; //導入方法依賴的package包/類
private Timeline createBlinker(Node node) {
Timeline blink = new Timeline(
new KeyFrame(
Duration.seconds(0),
new KeyValue(
node.opacityProperty(),
1,
Interpolator.DISCRETE
)
),
new KeyFrame(
Duration.seconds(0.35),
new KeyValue(
node.opacityProperty(),
0,
Interpolator.DISCRETE
)
),
new KeyFrame(
Duration.seconds(0.7),
new KeyValue(
node.opacityProperty(),
1,
Interpolator.DISCRETE
)
)
);
blink.setCycleCount(Animation.INDEFINITE);
return blink;
}
示例15: start
import javafx.util.Duration; //導入方法依賴的package包/類
public void start(Stage stage) throws IOException
{
Timeline timeline = new Timeline();
DateFormat dateFormat = new SimpleDateFormat("HH:mm:ss");
Date date = new Date();
timeline = new Timeline
(
new KeyFrame(Duration.seconds(0),
new EventHandler<ActionEvent>()
{
public void handle(ActionEvent actionEvent)
{
Date date = new Date();
Format formatter = new SimpleDateFormat("HH:mm:ss");
String inp = "17:46:52";
if(formatter.format(date).equals(inp))
{
mySound = "text.mp3";
media = new Media(new File(mySound).toURI().toString());
mediaPlayer = new MediaPlayer(media);
mediaPlayer.play();
}
}
}
),
new KeyFrame(Duration.seconds(1))
);
timeline.setCycleCount(Animation.INDEFINITE);
timeline.play();
}