Maven JFXtras JMetro
<dependencies>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-controls</artifactId>
<version>11.0.2</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-fxml</artifactId>
<version>11.0.2</version>
</dependency>
<dependency>
<groupId>org.jfxtras</groupId>
<artifactId>jmetro</artifactId>
<version>11.6.15</version>
</dependency>
</dependencies>
import javafx.application.Application;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.PasswordField;
import javafx.scene.control.TextField;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;
import jfxtras.styles.jmetro.JMetro;
import jfxtras.styles.jmetro.JMetroStyleClass;
import jfxtras.styles.jmetro.Style;
/**
* JavaFX App
*/
public class App extends Application {
@Override
public void start(Stage stage) {
// Champ texte TextField
TextField textField = new TextField();
textField.setPromptText("Email");
textField.setMaxWidth(200);
// Le champ mot de passe
PasswordField passwordField = new PasswordField();
passwordField.setPromptText("Mot de passe");
passwordField.setMaxWidth(200);
// Bouton
Button button = new Button("Se connecter");
// Applique le style pour le bouton
button.getStyleClass().add(JMetroStyleClass.LIGHT_BUTTONS);
// Couleur du bouton
button.setStyle("-fx-background-color: #0078D7;");
// Elément racine
VBox root = new VBox(textField, passwordField, button);
// Applique la couleur de fond pour l'élément racine
root.getStyleClass().add(JMetroStyleClass.BACKGROUND);
// Centré
root.setAlignment(Pos.CENTER);
// Espace de 10
root.setSpacing(10);
Scene scene = new Scene(root, 640, 480);
// Applique le style JMetro Sombre
JMetro jMetro = new JMetro(Style.DARK);
jMetro.setScene(scene);
stage.setScene(scene);
stage.show();
}
public static void main(String[] args) {
launch();
}
}
Commentaires
Enregistrer un commentaire