Code Source: Class FXMLDocumentController.java package jfoenix_example; import com.jfoenix.controls.JFXPasswordField; import com.jf...
Code Source:
Class FXMLDocumentController.java
package jfoenix_example;
import com.jfoenix.controls.JFXPasswordField;
import com.jfoenix.controls.JFXTextField;
import java.net.URL;
import java.util.ResourceBundle;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.Label;
import javax.swing.JOptionPane;
/**
*
* @author amir
*/
public class FXMLDocumentController implements Initializable {
@FXML
private JFXTextField username;
@FXML
private JFXPasswordField password;
@FXML
void Login(ActionEvent event) {
if(username.getText().equals("admin")&&password.getText().equals("12345")){
JOptionPane.showMessageDialog(null, "username and password is correct");
}else{
JOptionPane.showMessageDialog(null, "Fail");
}
}
@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.JFXPasswordField?>
<?import com.jfoenix.controls.JFXTextField?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.text.Font?>
<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/11.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="jfoenix_example.FXMLDocumentController">
<children>
<JFXButton buttonType="RAISED" layoutX="204.0" layoutY="263.0" onAction="#Login" prefHeight="49.0" prefWidth="193.0" ripplerFill="#dd31c4" style="-fx-background-color: green; -fx-background-radius: 45;" text="Login" textFill="WHITE">
<font>
<Font name="Times New Roman Bold" size="25.0" />
</font>
</JFXButton>
<JFXTextField fx:id="username" focusColor="#00f8e8" labelFloat="true" layoutX="180.0" layoutY="95.0" prefHeight="35.0" prefWidth="240.0" promptText="Enter Usrname" unFocusColor="RED" />
<JFXPasswordField fx:id="password" focusColor="#fff600" labelFloat="true" layoutX="181.0" layoutY="165.0" prefHeight="35.0" prefWidth="240.0" promptText="Enter Password" unFocusColor="#04ff29" />
</children>
</AnchorPane>
COMMENTS