0

I have been trying to add an InlineStyleTextArea and a CodeArea in anylayout both in the main method in javafx and in a fxml file. I receive a thread error. Please if possible with examples how can i add these components to a javafx layout? If possible with a tutorial link.

This is a simple code

public class Main extends Application {

@Override

public void start(Stage primaryStage) {
TextField myTextField = new TextField();
InlineCssTextArea TextArea = new InlineCssTextArea();

  HBox hbox = new HBox();
hbox.getChildren().add(myTextField);
hbox.getChildren().add(TextArea);
HBox.setHgrow(myTextField, Priority.ALWAYS);
HBox.setHgrow(TextArea, Priority.ALWAYS);

Scene scene = new Scene(hbox);
primaryStage.setScene(scene);
primaryStage.show();}

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


}

}

Exception in Application start method
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at sun.launcher.LauncherHelper$FXHelper.main(Unknown Source)
Caused by: java.lang.RuntimeException: Exception in Application start method
at com.sun.javafx.application.LauncherImpl.launchApplication1(Unknown Source)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$152(Unknown Source)
Caused by: java.lang.NoClassDefFoundError: org/reactfx/value/SuspendableVal
at application.Main.start(Main.java:20)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$159(Unknown Source)
at com.sun.javafx.application.LauncherImpl$$Lambda$53/19776028.run(Unknown Source)
at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$172(Unknown Source)
at com.sun.javafx.application.PlatformImpl$$Lambda$45/18503843.run(Unknown Source)
at com.sun.javafx.application.PlatformImpl.lambda$null$170(Unknown Source)
at com.sun.javafx.application.PlatformImpl$$Lambda$48/3799573.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.application.PlatformImpl.lambda$runLater$171(Unknown Source)
at com.sun.javafx.application.PlatformImpl$$Lambda$46/2180324.run(Unknown Source)
at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(Unknown Source)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.lambda$null$145(Unknown Source)
at com.sun.glass.ui.win.WinApplication$$Lambda$36/3326003.run(Unknown Source)
... 1 more
Caused by: java.lang.ClassNotFoundException: org.reactfx.value.SuspendableVal
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 15 more
Exception running application application.Main

at com.sun.javafx.application.LauncherImpl$$Lambda$50/14845382.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Mcjohn Key
  • 15
  • 8
  • They are just subclasses of control, so you add them in exactly the same way you add any other control. Can you post the stack trace you receive? – James_D Jan 07 '16 at 15:36
  • Exception in Application start method java.lang.reflect.InvocationTargetException at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) – Mcjohn Key Jan 07 '16 at 15:56
  • can i have just a simple example of a gui code?? – Mcjohn Key Jan 07 '16 at 16:01
  • Please include the **full** stack trace. [Edit] your question and paste it in there. You should also add the code that causes it. – James_D Jan 07 '16 at 16:05
  • So that's nothing to do with your code: it's a configuration problem. It looks like you either have a versioning problem with ReactFX, or the jar file is not in the classpath at execution time. – James_D Jan 07 '16 at 16:40
  • So how can i resolve the problem if the problem is at the level of versioning? – Mcjohn Key Jan 07 '16 at 16:48
  • 1
    Make sure you have the correct (in the sense of the same one as the one you are coding against) version of RichTextFX installed in the classpath. I usually use Maven to manage these, there are Maven coordinates on the RichTextFX site. RichTextFX also has a dependency on reactfx (and others?), iirc, so make sure you have the dependencies installed if you are managing it by hand. – James_D Jan 07 '16 at 17:02

1 Answers1

1

From the stack trace, it looks like the Java Runtime can't find (at least one class in) the ReactFX library, which is a dependency of RichTextFX. Since it gets as far as looking for that, it must have found InlineCssTextArea, so the RichTextFX library must be installed.

If you are using some kind of dependency management (Gradle or Maven, for example), that tool should manage all the dependencies for you.

If you are managing the dependencies by hand (i.e. downloading jar files and adding them to the classpath), you need to make sure you either download all the dependent jar files as well, or use the "Fat jar file".

James_D
  • 201,275
  • 16
  • 291
  • 322