JavaFX JFoenix TextField KeyEvent

Diskutiere JavaFX JFoenix TextField KeyEvent im AWT, Swing, JavaFX & SWT Forum; guten morgen eine frage könnte mir jemand mit JFoenix weiterhelfen ??? mein problem ist ich habe eine JFXTextfield und möchte dieses mit einem...

  1. Bluedaishi
    Bluedaishi Mitglied
    guten morgen eine frage könnte mir jemand mit JFoenix weiterhelfen ???
    mein problem ist ich habe eine JFXTextfield und möchte dieses mit einem KeyEvent "verknüpfen" wenn
    die entertaste gedückt wird aber satt dessen bekomme ich immer eine Exception.


    FXMLController
    Code (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 login_fxl;

    import com.jfoenix.controls.JFXButton;
    import com.jfoenix.controls.JFXPasswordField;
    import com.jfoenix.controls.JFXTextField;
    import java.awt.event.KeyEvent;
    import java.net.URL;
    import java.sql.SQLException;
    import java.util.ResourceBundle;
    import javafx.fxml.FXML;
    import javafx.fxml.Initializable;
    import javafx.scene.control.Label;



    /**
    *
    * @author KeinerEiner
    */

    public class FXMLDocumentController implements Initializable {

        String user_str_e = "";
        String user_pw_str_e = "";

        @FXML
        private Label label;
        private JFXTextField user;
        private JFXPasswordField pwf;
        private JFXButton btn_login;

        private String user_str;
        private String user_pw_str;

        @FXML
        public void handleKeyUserAction(KeyEvent event) throws ClassNotFoundException, InstantiationException, IllegalAccessException, SQLException {
           
        }

        @Override
        public void initialize(URL url, ResourceBundle rb) {

        }
    }
     
    FXMLDocument.fxml
    Code (CSS):
    <?xml version="1.0" encoding="UTF-8"?>

    <?import javafx.scene.paint.*?>
    <?import javafx.scene.image.*?>
    <?import javafx.scene.text.*?>
    <?import javafx.scene.effect.*?>
    <?import com.jfoenix.controls.*?>
    <?import java.lang.*?>
    <?import javafx.scene.control.*?>
    <?import javafx.scene.layout.*?>

    <AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="500.0" prefWidth="792.0" style="-fx-background-color: #1d1d1d;" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="login_fxl.FXMLDocumentController">
       <children>
          <ImageView fitHeight="500.0" fitWidth="792.0" layoutX="-1.0" layoutY="-1.0" pickOnBounds="true">
             <image>
                <Image url="@../Images/bg-7.jpg" />
             </image>
          </ImageView>
          <AnchorPane layoutX="250.0" layoutY="41.0" opacity="0.89" prefHeight="417.0" prefWidth="318.0" style="-fx-background-color: #3FC4E6;">
             <children>
                <JFXTextField fx:id="user" focusColor="#20285d" labelFloat="true" layoutX="27.0" layoutY="119.0" onAction="#handleKeyUserAction" prefHeight="30.0" prefWidth="265.0" promptText="Username" style="-fx-text-fill: #121343;" unFocusColor="#f2eeee">
                   <font>
                      <Font name="System Bold" size="14.0" />
                   </font>
                </JFXTextField>
                <JFXPasswordField fx:id="pwf" focusColor="#20285d" labelFloat="true" layoutX="28.0" layoutY="191.0" prefHeight="30.0" prefWidth="265.0" promptText="Password" unFocusColor="#f8f5f5">
                   <font>
                      <Font name="System Bold" size="14.0" />
                   </font>
                </JFXPasswordField>
                <JFXButton fx:id="btn_login" buttonType="RAISED" layoutX="26.0" layoutY="281.0" onAction="#handleButtonAction_login" prefHeight="30.0" prefWidth="265.0" style="-fx-background-color: #20386D;" text="Login" textFill="#f8f6f6">
                   <font>
                      <Font name="System Bold" size="16.0" />
                   </font>
                   <ripplerFill>
                      <LinearGradient endX="1.0" endY="1.0">
                         <stops>
                            <Stop color="BLACK" />
                            <Stop color="BLACK" offset="0.007662835249042145" />
                            <Stop color="WHITE" offset="1.0" />
                         </stops>
                      </LinearGradient>
                   </ripplerFill>
                </JFXButton>
                <Label layoutX="84.0" layoutY="26.0" text="Welcome" textFill="#0a55f5">
                   <font>
                      <Font name="System Bold" size="36.0" />
                   </font>
                </Label>
             </children>
          </AnchorPane>
       </children>
    </AnchorPane>
     
    Exception
    Code (Text):
    Executing C:\Users\KeinerEiner\Documents\NetBeansProjects\Login_FXL\dist\run932012235\Login_FXL.jar using platform C:\Program Files\Java\jdk1.8.0_152\jre/bin/java
    Exception in Application start method
    java.lang.reflect.InvocationTargetException
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:389)
        at com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:328)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at sun.launcher.LauncherHelper$FXHelper.main(LauncherHelper.java:767)
    Caused by: java.lang.RuntimeException: Exception in Application start method
        at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:917)
        at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$154(LauncherImpl.java:182)
        at java.lang.Thread.run(Thread.java:748)
    Caused by: javafx.fxml.LoadException: Error resolving onAction='#handleKeyUserAction', either the event handler is not in the Namespace or there is an error in the script.
    file:/C:/Users/KeinerEiner/Documents/NetBeansProjects/Login_FXL/dist/run932012235/Login_FXL.jar!/login_fxl/FXMLDocument.fxml:25

        at javafx.fxml.FXMLLoader.constructLoadException(FXMLLoader.java:2597)
        at javafx.fxml.FXMLLoader.access$100(FXMLLoader.java:103)
        at javafx.fxml.FXMLLoader$Element.processEventHandlerAttributes(FXMLLoader.java:610)
        at javafx.fxml.FXMLLoader$ValueElement.processEndElement(FXMLLoader.java:770)
        at javafx.fxml.FXMLLoader.processEndElement(FXMLLoader.java:2823)
        at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2532)
        at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2441)
        at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3214)
        at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3175)
        at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3148)
        at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3124)
        at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3104)
        at javafx.fxml.FXMLLoader.load(FXMLLoader.java:3097)
        at login_fxl.Login_FXL.start(Login_FXL.java:22)
        at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$161(LauncherImpl.java:863)
        at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$174(PlatformImpl.java:326)
        at com.sun.javafx.application.PlatformImpl.lambda$null$172(PlatformImpl.java:295)
        at java.security.AccessController.doPrivileged(Native Method)
        at com.sun.javafx.application.PlatformImpl.lambda$runLater$173(PlatformImpl.java:294)
        at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
        at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
        at com.sun.glass.ui.win.WinApplication.lambda$null$147(WinApplication.java:177)
        ... 1 more
    Exception running application login_fxl.Login_FXL
    Java Result: 1
    hoffe es kann mir jemand weiterhelfen
     
  2. Vielleicht hilft dir dieser Kurs hier weiter.
  3. mihe7
    mihe7 Bekanntes Mitglied
    Code (Text):

    Caused by: javafx.fxml.LoadException: Error resolving onAction='#handleKeyUserAction', either the event handler is not in the Namespace or there is an error in the script.
     
    Wenn ich mir https://docs.oracle.com/javase/8/javafx/api/javafx/event/EventHandler.html ansehe, dann wirft die handle-Methode keine Exceptions. Ändere mal
    Code (Java):

    public void handleKeyUserAction(KeyEvent event) throws ClassNotFoundException, InstantiationException, IllegalAccessException, SQLException {
     
    zu
    Code (Java):

    public void handleKeyUserAction(KeyEvent event) {
     
    Nachtrag: und statt KeyEvent verwende mal ActionEvent.
     
  4. Bluedaishi
    Bluedaishi Mitglied
    Ja da lag mein Fehler ich habe den KeyEvent über den SceneBuilder einem ActionEvent zugewiesen das funktioniert nicht :) Danke für deine Hilfe
     
  5. Wenn du Java lernen möchtest, empfehlen wir dir diesen Kurs hier
Passende Stellenanzeigen aus deiner Region:





Die Seite wird geladen...

JavaFX JFoenix TextField KeyEvent - Ähnliche Themen

JavaFX Tutorial
JavaFX Tutorial im Forum AWT, Swing, JavaFX & SWT
JavaFx TreeView mit file system
JavaFx TreeView mit file system im Forum AWT, Swing, JavaFX & SWT
JavaFX Button Image aus Datenbank
JavaFX Button Image aus Datenbank im Forum AWT, Swing, JavaFX & SWT
JavaFX-Übung Autospiel
JavaFX-Übung Autospiel im Forum Java Basics - Anfänger-Themen
JavaFX: Fenster bleibt weiß
JavaFX: Fenster bleibt weiß im Forum Java Basics - Anfänger-Themen
Thema: JavaFX JFoenix TextField KeyEvent