Estou a tentar aprender sozinho o desenvolvimento de aplicações com o javafx. Criei uma interface em scene builder mas agora nao sei criar um codigo para ela.
Tenho um codigo em java:
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package material.login;
import java.io.IOException;
import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.control.TextField;
import javafx.stage.Stage;
import javafx.stage.StageStyle;
/**
*
* @author danml
*/
public class MaterialLogin extends Application {
@FXML
private TextField user;
@FXML
private TextField password;
@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.initStyle(StageStyle.TRANSPARENT);
stage.show();
}
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
launch(args);
}
}
E o codigo em javafx:
<?xml version="1.0" encoding="UTF-8"?>
<?import com.jfoenix.controls.JFXButton?>
<?import com.jfoenix.controls.JFXCheckBox?>
<?import com.jfoenix.controls.JFXPasswordField?>
<?import com.jfoenix.controls.JFXTextField?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.image.Image?>
<?import javafx.scene.image.ImageView?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.layout.Pane?>
<?import javafx.scene.layout.StackPane?>
<?import javafx.scene.layout.VBox?>
<?import javafx.scene.text.Font?>
<AnchorPane id="AnchorPane" prefHeight="550.0" prefWidth="800.0" xmlns="http://javafx.com/javafx/11.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="material.login.FXMLDocumentController">
<children>
<StackPane layoutX="184.0" layoutY="100.0" prefHeight="550.0" prefWidth="800.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<children>
<VBox prefHeight="200.0" prefWidth="100.0">
<children>
<Pane prefHeight="200.0" prefWidth="200.0" style="-fx-background-color: #2196f3;" />
<Pane prefHeight="351.0" prefWidth="800.0" style="-fx-background-color: #EDE7F6;" />
</children>
</VBox>
<AnchorPane prefHeight="486.0" prefWidth="800.0" style="-fx-background-color: transparent;">
<children>
<AnchorPane layoutX="166.0" layoutY="113.0" prefHeight="342.0" prefWidth="469.0" style="-fx-background-color: WHITE; -fx-effect: dropshadow(gaussian, rgb(0.0, 0.0, 0.0, 0.15), 6.0, 0.7, 0.0,1.5); -fx-background-radius: 19; -fx-border-radius: 67; -fx-padding: 8;">
<children>
<ImageView fitHeight="85.0" fitWidth="107.0" layoutX="185.0" layoutY="14.0" pickOnBounds="true" preserveRatio="true">
<image>
<Image url="@24.jpg" />
</image>
</ImageView>
<JFXTextField id="user" fx:id="user" labelFloat="true" layoutX="75.0" layoutY="147.0" maxWidth="316.0" minWidth="233.0" prefHeight="31.0" prefWidth="316.0" promptText="Enter Username">
<font>
<Font name="Roboto Medium" size="14.0" />
</font>
</JFXTextField>
<JFXPasswordField id="password" fx:id="password" labelFloat="true" layoutX="75.0" layoutY="195.0" maxWidth="316.0" minWidth="235.0" prefHeight="31.0" prefWidth="316.0" promptText="Enter password">
<font>
<Font name="Roboto Medium" size="14.0" />
</font>
</JFXPasswordField>
<JFXCheckBox checkedColor="#ff1744" layoutX="75.0" layoutY="244.0" prefHeight="31.0" prefWidth="171.0" text="Keep me logged in">
<font>
<Font name="Roboto Regular" size="14.0" />
</font>
</JFXCheckBox>
<JFXButton id="login" layoutX="185.0" layoutY="286.0" onAction="#login" prefHeight="32.0" prefWidth="100.0" style="-fx-background-color: #2196f3;" text="Login" textFill="WHITE">
<font>
<Font name="Roboto Bold" size="14.0" />
</font>
</JFXButton>
<JFXButton layoutX="348.0" layoutY="290.0" />
</children>
</AnchorPane>
<VBox layoutX="188.0" layoutY="24.0">
<children>
<Label alignment="CENTER" prefHeight="34.0" prefWidth="425.0" text="LOGIN" textAlignment="CENTER" textFill="WHITE">
<font>
<Font name="Roboto Bold" size="18.0" />
</font>
</Label>
</children>
</VBox>
<ImageView fitHeight="550.0" fitWidth="800.0" pickOnBounds="true" preserveRatio="true" />
</children>
</AnchorPane>
</children>
</StackPane>
</children>
</AnchorPane>
Alguem me consegue ajudar a jutar os dois! Obrigado