Welcome to the forum 👋, Guest

To access the forum content and all our services, you must register or log in to the forum. Becoming a member of the forum is completely free.

  • PËRSHËNDETJE VIZITOR!

    Nëse ju shfaqet ky mesazh do të thotë se ju nuk jeni regjistruar akoma. Anëtarët e rregjistruar kanë privilegjin të marrin pjesë në tema të ndryshme si dhe të komunikojnë me anëtarët e tjerë. Bëhu pjesë e forumit Netedy.com duke u REGJISTRUAR këtu ose nëse ke një llogari KYCU. Komunikim alternative i ketij forumi me vajza dhe djem nga te gjithe trevat shqiptare? Hyr ne: CHAT SHQIP.

[JavaFX] Beginners login layout + function

centos

ⓃⒺⓉⒺⒹⓎ.ⒸⓄⓂ
ANETAR ✓
Regjistruar më
Dhj 13, 2004
Mesazhe
39,815
Ne kte projekt eshte perdorur NetBeans IDE 10.0 & Scene Builder

Struktura:
Main : src/main/beginnersLogin
Controllers: src/main/beginnersLogin/controllers
View : src/main/beginnersLogin/view


beginnersLogin.java # $Main/beginnersLogin.java
Java:
package beginnersLogin;

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.stage.Stage;

/**
 *
 * @author molecule
 */
public class beginnersLogin extends Application {
static Stage stg;
    @Override
    public void start(Stage stage) throws Exception {
        Parent root = FXMLLoader.load(getClass().getResource("/view/login.fxml"));
        stage.setTitle("beginnersLogin - Login");
        Scene scene = new Scene(root);
        stage.setScene(scene);
        stage.show();
    }
    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        launch(args);
    }
    
}

Controller.java
Java:
package beginnersLogin.controllers;

import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.control.PasswordField;
import javafx.scene.control.TextField;


public class Controller {
    @FXML
    private Button login;
    @FXML
    private PasswordField password;
    @FXML
    private TextField user;
    @FXML
    private void initialize() {
      // copyright.setText("powered by molecule@netedyforum");
    }
 
        @FXML
    private void handleButtonAction(ActionEvent event) {
     // printojme user & pass
         System.out.println("Login clicked");
        System.out.println("USER: "+user.getText());
        System.out.println("Password:"+password.getText());
    }
}

login.fxml
Java:
<?xml version="1.0" encoding="UTF-8"?>

<?import javafx.scene.control.Button?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.control.PasswordField?>
<?import javafx.scene.control.TextField?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.layout.VBox?>
<?import javafx.scene.text.Font?>

<VBox prefHeight="400.0" prefWidth="640.0" xmlns="http://javafx.com/javafx/10.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="beginnersLogin.controllers.Controller">
  <children>
    <AnchorPane maxHeight="-1.0" maxWidth="-1.0" prefHeight="-1.0" prefWidth="-1.0" VBox.vgrow="ALWAYS">
      <children>
        <Label fx:id="copyright" alignment="CENTER" layoutX="113.0" layoutY="314.0" prefHeight="72.0" prefWidth="415.0" text="powerd by molecule@netedyforum" textAlignment="CENTER" textFill="#979494">
           <font>
              <Font name="Arial" size="14.0" />
           </font>
        </Label>
            <TextField id="user" fx:id="user" accessibleHelp="Perdoruesi" layoutX="189.0" layoutY="96.0" prefHeight="42.0" prefWidth="263.0" promptText="Perdoruesi" />
            <Label layoutX="189.0" layoutY="72.0" prefHeight="24.0" prefWidth="93.0" text="Perdoruesi:" />
            <Label layoutX="189.0" layoutY="149.0" prefHeight="24.0" prefWidth="93.0" text="Passwordi:" />
            <PasswordField id="password" fx:id="password" layoutX="189.0" layoutY="179.0" prefHeight="42.0" prefWidth="263.0" promptText="Passwordi" />
            <Button id="login" fx:id="login" accessibleText="LOGIN" layoutX="224.0" layoutY="257.0" mnemonicParsing="false" onAction="pressButton" prefHeight="42.0" prefWidth="194.0" style="-fx-background-color: #31a8f8;" text="LOGIN" textFill="WHITE">
               <font>
                  <Font name="Arial" size="20.0" />
               </font>
            </Button>
      </children>
    </AnchorPane>
  </children>
</VBox>


Rezultati:

J06qdk_3T6epf5YLdDnnuQ.png
 

Postime të reja

Theme customization system

You can customize some areas of the forum theme from this menu.

Choose the color combination according to your taste

Select Day/Night mode

You can use it by choosing the day and night modes that suit your style or needs.

Welcome to the forum 👋, Guest

To access the forum content and all our services, you must register or log in to the forum. Becoming a member of the forum is completely free.