Class FXMLDocumentController.java package javafxapplication27; import com.jfoenix.controls.JFXProgressBar; import java.net.URL; imp...
Class FXMLDocumentController.java
package javafxapplication27;
import com.jfoenix.controls.JFXProgressBar;
import java.net.URL;
import java.util.ResourceBundle;
import javafx.animation.KeyFrame;
import javafx.animation.KeyValue;
import javafx.animation.Timeline;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.util.Duration;
import javax.swing.JOptionPane;
/**
*
* @author amir
*/
public class FXMLDocumentController implements Initializable {
@FXML
private JFXProgressBar p1;
@FXML
void login(ActionEvent event) {
Timeline timeline = new Timeline();
KeyValue keyvalue1 = new KeyValue(p1.progressProperty(), 0.01);
KeyFrame frame1 = new KeyFrame(Duration.millis(500), keyvalue1);
KeyValue keyvalue2 = new KeyValue(p1.progressProperty(), 1);
KeyFrame frame2 = new KeyFrame(Duration.millis(2000), keyvalue2);
timeline.getKeyFrames().addAll(frame1,frame2);
timeline.play();
timeline.setOnFinished(e ->{
JOptionPane.showMessageDialog(null, "succes");
});
}
@Override
public void initialize(URL url, ResourceBundle rb) {
// TODO
}
}
FXMLDocument.fxml
<?xml version="1.0" encoding="UTF-8"?>
<?import com.jfoenix.controls.JFXButton?>
<?import com.jfoenix.controls.JFXProgressBar?>
<?import com.jfoenix.controls.JFXTextField?>
<?import javafx.scene.layout.AnchorPane?>
<AnchorPane id="AnchorPane" prefHeight="324.0" prefWidth="348.0" xmlns="http://javafx.com/javafx/11.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="javafxapplication27.FXMLDocumentController">
<children>
<JFXProgressBar fx:id="p1" layoutX="74.0" layoutY="208.0" progress="0.0" />
<JFXButton layoutX="148.0" layoutY="252.0" onAction="#login" style="-fx-background-color: green;" text="Login" />
<JFXTextField layoutX="107.0" layoutY="82.0" />
<JFXTextField layoutX="107.0" layoutY="137.0" />
</children>
</AnchorPane>
Class JavaFXApplication27.java
package javafxapplication27;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;
/**
*
* @author amir
*/
public class JavaFXApplication27 extends Application {
@Override
public void start(Stage stage) throws Exception {
Parent root = FXMLLoader.load(getClass().getResource("FXMLDocument.fxml"));
Scene scene = new Scene(root);
stage.setScene(scene);
stage.show();
}
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
launch(args);
}
}
COMMENTS