jfoenix与eclipse的结合

kwvwclae  于 2021-07-08  发布在  Java
关注(0)|答案(0)|浏览(407)

我在eclipse上尝试使用jfoenix已经有相当一段时间了,但它似乎从来都不起作用。如果这里有人能帮我,我将不胜感激。我的jdk是12.02,scenebuilder版本是8.5.0,eclipse2019-12,除了jfoenix 8.0.10,java版本8更新261。我把所有的路都弄清楚了,它就是跑不动。我可以在没有jfoenix库的情况下运行应用程序,但我需要我的应用程序美观。以下是错误:

Exception in Application start method
java.lang.reflect.InvocationTargetException
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:567)
    at javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:464)
    at javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:363)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:567)
    at java.base/sun.launcher.LauncherHelper$FXHelper.main(LauncherHelper.java:1051)
Caused by: java.lang.RuntimeException: Exception in Application start method
    at javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:900)
    at javafx.graphics/com.sun.javafx.application.LauncherImpl.lambda$launchApplication$2(LauncherImpl.java:195)
    at java.base/java.lang.Thread.run(Thread.java:835)
Caused by: java.lang.NoClassDefFoundError: com/sun/javafx/css/converters/PaintConverter
    at com.jfoenix.controls.JFXTextField$StyleableProperties.<clinit>(JFXTextField.java:241)
    at com.jfoenix.controls.JFXTextField.<init>(JFXTextField.java:146)
    at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:500)
    at java.base/java.lang.reflect.ReflectAccess.newInstance(ReflectAccess.java:166)
    at java.base/jdk.internal.reflect.ReflectionFactory.newInstance(ReflectionFactory.java:404)
    at java.base/java.lang.Class.newInstance(Class.java:590)
    at javafx.fxml/javafx.fxml.FXMLLoader$InstanceDeclarationElement.constructValue(FXMLLoader.java:1019)
    at javafx.fxml/javafx.fxml.FXMLLoader$ValueElement.processStartElement(FXMLLoader.java:754)
    at javafx.fxml/javafx.fxml.FXMLLoader.processStartElement(FXMLLoader.java:2722)
    at javafx.fxml/javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2552)
    at javafx.fxml/javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2466)
    at javafx.fxml/javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3237)
    at javafx.fxml/javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3194)
    at javafx.fxml/javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3163)
    at javafx.fxml/javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3136)
    at javafx.fxml/javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3113)
    at javafx.fxml/javafx.fxml.FXMLLoader.load(FXMLLoader.java:3106)
    at application.Main.start(Main.java:13)
    at javafx.graphics/com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$9(LauncherImpl.java:846)
    at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runAndWait$12(PlatformImpl.java:455)
    at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:428)
    at java.base/java.security.AccessController.doPrivileged(AccessController.java:389)
    at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:427)
    at javafx.graphics/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96)
    at javafx.graphics/com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
    at javafx.graphics/com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(WinApplication.java:174)
    ... 1 more
Caused by: java.lang.ClassNotFoundException: com.sun.javafx.css.converters.PaintConverter
    at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:583)
    at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
    ... 30 more
Exception running application application.Main
package application;

import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;

public class Main extends Application {
    @Override
    public void start(Stage primaryStage) {
        try {
            Parent root = FXMLLoader.load(getClass().getResource("/application/HomePage.fxml"));
            Scene scene = new Scene(root,1000,800);
            scene.getStylesheets().add(getClass().getResource("application.css").toExternalForm());
            primaryStage.setScene(scene);
            primaryStage.show();
        } catch(Exception e) {
            e.printStackTrace();
        }
    }

    public static void main(String[] args) {
        launch(args);
    }
}

代码^

<?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.Cursor?>
<?import javafx.scene.Group?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.control.Tab?>
<?import javafx.scene.control.TabPane?>
<?import javafx.scene.effect.DropShadow?>
<?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.text.Font?>

<StackPane xmlns="http://javafx.com/javafx/8.0.171" xmlns:fx="http://javafx.com/fxml/1" fx:controller="Controllers.HomePageLoginController">
   <children>
      <AnchorPane prefHeight="644.0" prefWidth="940.0" style="-fx-background-color: #8ED5FF;">
         <children>
            <AnchorPane layoutX="394.0" layoutY="7.0" prefHeight="630.0" prefWidth="529.0" style="-fx-background-color: #FFFF; -fx-background-radius: 10px;">
               <effect>
                  <DropShadow color="#0617b5" />
               </effect>
               <children>
                  <TabPane fx:id="tabPane" layoutX="1.0" layoutY="100.0" prefHeight="483.0" prefWidth="528.0" tabClosingPolicy="UNAVAILABLE">
                    <tabs>
                      <Tab fx:id="employeeTab" text="Employee">
                           <content>
                              <AnchorPane prefHeight="200.0" prefWidth="200.0">
                                 <children>
                                    <JFXTextField fx:id="employeeUsernameText" focusColor="#1357cf" labelFloat="true" layoutX="125.0" layoutY="138.0" prefHeight="31.0" prefWidth="304.0" promptText="Employee Username" unFocusColor="#4d4d4d">
                                       <font>
                                          <Font name="Constantia Bold" size="19.0" />
                                       </font>
                                    </JFXTextField>
                                    <JFXPasswordField fx:id="EmployeePasswordTab" focusColor="#1357cf" labelFloat="true" layoutX="126.0" layoutY="215.0" prefHeight="31.0" prefWidth="304.0" promptText="Employee Password">
                                       <font>
                                          <Font name="Constantia Bold" size="19.0" />
                                       </font>
                                    </JFXPasswordField>
                                    <Label alignment="CENTER" contentDisplay="CENTER" layoutX="21.0" layoutY="400.0" prefHeight="21.0" prefWidth="469.0" text="Welcome Label">
                                       <font>
                                          <Font name="Constantia Italic" size="15.0" />
                                       </font>
                                    </Label>
                                    <JFXButton fx:id="employeeLogin" layoutX="217.0" layoutY="303.0" style="-fx-background-color: #8ED5FF; -fx-background-radius: 10px;" text="Login">
                                       <font>
                                          <Font name="Constantia Bold" size="19.0" />
                                       </font>
                                    </JFXButton>
                                 </children>
                              </AnchorPane>
                           </content>
                        </Tab>
                      <Tab fx:id="tabClient" text="Client">
                           <content>
                              <AnchorPane prefHeight="432.0" prefWidth="528.0">
                                 <children>
                                    <JFXTextField fx:id="clientUsernameText" focusColor="#1357cf" labelFloat="true" layoutX="125.0" layoutY="138.0" prefHeight="31.0" prefWidth="304.0" promptText="Client Username" unFocusColor="#4d4d4d">
                                       <font>
                                          <Font name="Constantia Bold" size="19.0" />
                                       </font>
                                    </JFXTextField>
                                    <JFXPasswordField fx:id="clientPasswordText" focusColor="#1357cf" labelFloat="true" layoutX="126.0" layoutY="215.0" prefHeight="31.0" prefWidth="304.0" promptText="Client Password">
                                       <font>
                                          <Font name="Constantia Bold" size="19.0" />
                                       </font>
                                    </JFXPasswordField>
                                    <JFXButton fx:id="clientLoginButton" layoutX="224.0" layoutY="305.0" prefHeight="35.0" prefWidth="89.0" style="-fx-background-color: #8ED5FF; -fx-background-radius: 10px;" text="Login">
                                       <font>
                                          <Font name="Constantia Bold" size="18.0" />
                                       </font>
                                    </JFXButton>
                                    <Label alignment="CENTER" contentDisplay="CENTER" layoutX="21.0" layoutY="400.0" prefHeight="21.0" prefWidth="469.0" text="Welcome Label Client">
                                       <font>
                                          <Font name="Constantia Italic" size="15.0" />
                                       </font>
                                    </Label>
                                 </children>
                              </AnchorPane>
                           </content>
                        </Tab>
                    </tabs>
                  </TabPane>
                  <Group layoutX="68.0" layoutY="47.0">
                     <children>
                        <Pane fx:id="slidingPane" layoutX="6.0" layoutY="1.0" prefHeight="35.0" prefWidth="368.0">
                           <children>
                              <Label fx:id="employeeStatus" alignment="CENTER" onMouseClicked="#openEmployee" prefHeight="35.0" prefWidth="158.0" style="-fx-font-weight: 700;" text="EMPLOYEE" textAlignment="CENTER">
                                 <font>
                                    <Font name="System Bold" size="15.0" />
                                 </font>
                              </Label>
                              <Label fx:id="clientLabelStatus" alignment="CENTER" layoutX="174.0" layoutY="-1.0" onMouseClicked="#openClient" prefHeight="35.0" prefWidth="197.0" style="-fx-font-weight: 700;" text="CLIENT" textAlignment="CENTER">
                                 <font>
                                    <Font name="System Bold" size="15.0" />
                                 </font>
                              </Label>
                           </children>
                        </Pane>
                        <Label fx:id="labelStatus" alignment="CENTER" layoutY="1.0" prefHeight="37.0" prefWidth="167.0" style="-fx-background-color: #8ED5FF; -fx-background-radius: 10px;" text="EMPLOYEE">
                           <cursor>
                              <Cursor fx:constant="DEFAULT" />
                           </cursor>
                        </Label>
                     </children>
                  </Group>
               </children>
            </AnchorPane>
            <AnchorPane layoutX="41.0" layoutY="132.0">
               <children>
                  <ImageView fitHeight="353.0" fitWidth="414.0" layoutX="-25.0" layoutY="10.0" pickOnBounds="true" preserveRatio="true">
                     <image>
                        <Image url="@../../../../Downloads/imageedit_1_7896082891.png" />
                     </image>
                  </ImageView>
               </children>
               <effect>
                  <DropShadow color="WHITE" />
               </effect>
            </AnchorPane>
         </children>
      </AnchorPane>
   </children>
</StackPane>

fxml文档^请帮助

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题