Chào các anh,chị
Hiện tại em đang học JavaFx, và em setup như trên youtube chỉ, nhưng không chạy được
File Login.fxml
<?xml version="1.0" encoding="UTF-8"?>
<?import com.jfoenix.controls.JFXButton?>
<?import com.jfoenix.controls.JFXPasswordField?>
<?import com.jfoenix.controls.JFXTextField?>
<?import de.jensd.fx.glyphs.fontawesome.FontAwesomeIconView?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.layout.BorderPane?>
<?import javafx.scene.text.Font?>
<?import javafx.scene.text.Text?>
<BorderPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="500.0" prefWidth="700.0" stylesheets="@login.css" xmlns="http://javafx.com/javafx/11.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="UI.LoginController">
<left>
<AnchorPane prefHeight="500.0" prefWidth="350.0" styleClass="left_pane" BorderPane.alignment="CENTER">
<children>
<FontAwesomeIconView fill="WHITE" glyphName="BOOK" layoutX="147.0" layoutY="212.0" size="60" />
<Text fill="WHITE" layoutX="74.0" layoutY="278.0" strokeType="OUTSIDE" strokeWidth="0.0" text="Library Manager">
<font>
<Font name="System Bold" size="26.0" />
</font>
</Text>
</children>
</AnchorPane>
</left>
<right>
<AnchorPane prefHeight="200.0" prefWidth="350.0" BorderPane.alignment="CENTER">
<children>
<JFXTextField focusColor="#017fff" layoutX="95.0" layoutY="237.0" prefHeight="26.0" prefWidth="160.0" promptText="USER NAME" />
<JFXPasswordField focusColor="#017fff" layoutX="95.0" layoutY="292.0" prefHeight="26.0" prefWidth="160.0" promptText="PASSWORD" />
<FontAwesomeIconView fill="#017fff" glyphName="USERS" layoutX="143.0" layoutY="128.0" size="60" />
<Text fill="#017fff" layoutX="128.0" layoutY="180.0" strokeType="OUTSIDE" strokeWidth="0.0" text="User Login">
<font>
<Font size="20.0" />
</font>
</Text>
<FontAwesomeIconView fill="#017fff" glyphName="USER" layoutX="68.0" layoutY="257.0" size="20" />
<FontAwesomeIconView fill="#017fff" glyphName="KEY" layoutX="65.0" layoutY="312.0" size="20" />
<JFXButton layoutX="154.0" layoutY="352.0" prefHeight="42.0" prefWidth="106.0" styleClass="btn_login" text="Login" textFill="WHITE" />
</children>
</AnchorPane>
</right>
</BorderPane>
file Login_Main.java
package Appllication;
import java.io.IOException;
import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.input.MouseEvent;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;
import javafx.stage.StageStyle;
/**
*
* @author pc
*/
public class Login_Main extends Application {
private double xOffset = 0;
private double yOffset = 0;
@Override
public void start(Stage primaryStage) throws Exception {
Parent root = FXMLLoader.load(getClass().getResource("./UI/Login.fxml"));
Scene scene = new Scene(root);
root.setOnMousePressed(new EventHandler<MouseEvent>(){
@Override
public void handle(MouseEvent event){
xOffset = event.getSceneX();
yOffset = event.getSceneY();
}
});
root.setOnMouseDragged(new EventHandler<MouseEvent>(){
@Override
public void handle(MouseEvent event){
primaryStage.setX(event.getSceneX() - xOffset);
primaryStage.setY(event.getSceneY() - yOffset);
}
});
primaryStage.initStyle(StageStyle.DECORATED.UNDECORATED);
primaryStage.setScene(scene);
primaryStage.show();
}
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
launch(args);
}
}
file LoginController.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 UI;
import java.net.URL;
import java.util.ResourceBundle;
import javafx.fxml.Initializable;
/**
* FXML Controller class
*
* @author pc
*/
public class LoginController implements Initializable {
/**
* Initializes the controller class.
*/
@Override
public void initialize(URL url, ResourceBundle rb) {
// TODO
}
}
Lỗi hiện tại em gặp phải là :
C:\Users\pc\Desktop\java\Library\nbproject\jfx-impl.xml:3597: The following error occurred while executing this line:
C:\Users\pc\Desktop\java\Library\nbproject\jfx-impl.xml:1251: The following error occurred while executing this line:
C:\Users\pc\Desktop\java\Library\nbproject\jfx-impl.xml:1259: Unable to create javax script engine for javascript