0

I have basically only a not coded Gui, and still got that exception although had some working guis before with a little code. so what confuses most.. There's basically only a gui and there isnt much code to delete, fix.. so why this gui isn't showing up? p.s. fxml is in the right directory, for sure

MAIN

package application;

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



public class Main extends Application {

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

}

@Override
public void start(Stage stage) throws Exception {

        AnchorPane pane =  FXMLLoader.load(getClass().getResource("Gui.fxml"));
    Scene scene = new Scene(pane);
    stage.setScene(scene);
    stage.show();


}
}

CONTROLLER

public class Controller implements Initializable {
DropShadow ds = new DropShadow();
@FXML
ButtonGroup group;
@FXML
RadioButton radio1;
@FXML
RadioButton radio2;
@FXML
RadioButton radio3;
@FXML
Label changelog;
@FXML
TextArea changelogarea;
@FXML
Pane panechange;
@FXML
AnchorPane mainanchor;

Controller(){
changelog.setEffect(ds);    
}







@Override
public void initialize(URL location, ResourceBundle resources) {
    // TODO Auto-generated method stub

}

}

FXML

<?import javafx.scene.text.*?>
<?import javafx.scene.*?>
<?import javafx.scene.control.*?>
<?import java.lang.*?>
<?import javafx.scene.layout.*?>
<?import javafx.scene.layout.AnchorPane?>


<AnchorPane fx:id="mainanchor" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="application.Controller">
   <children>
      <Pane fx:id="panechange" layoutX="106.0" layoutY="-3.0" prefHeight="406.0" prefWidth="493.0">
     <children>
        <Label fx:id="changelog" layoutX="20.0" layoutY="21.0" prefHeight="49.0" prefWidth="463.0" text="                     Change log" textAlignment="CENTER">
           <font>
              <Font size="27.0" />
           </font>
        </Label>
        <TextArea fx:id="changelogarea" layoutX="1.0" layoutY="70.0" prefHeight="329.0" prefWidth="487.0" />
     </children>
  </Pane>
  <RadioButton fx:id="radio2" layoutX="14.0" layoutY="62.0" mnemonicParsing="false" text="Valiuta">
     <toggleGroup>
        <ToggleGroup fx:id="group" />
     </toggleGroup>
  </RadioButton>
  <RadioButton fx:id="radio3" layoutX="14.0" layoutY="94.0" mnemonicParsing="false" text="Atstumai" toggleGroup="$group" />
  <RadioButton fx:id="radio1" layoutX="14.0" layoutY="32.0" mnemonicParsing="false" selected="true" text="Naujienos" toggleGroup="$group" />
   </children>
</AnchorPane>

error

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:483) at com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherIm pl.java:363) at com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java: 303) 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:483) 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 :875) at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$147(Launche rImpl.java:157) at com.sun.javafx.application.LauncherImpl$$Lambda$48/128893786.run(Unknown Sou rce) at java.lang.Thread.run(Thread.java:745) Caused by: javafx.fxml.LoadException: /E:/Programming/Java/WorkSpace/FxConverter/bin/application/Gui.fxml:11

at javafx.fxml.FXMLLoader.constructLoadException(FXMLLoader.java:2595) at javafx.fxml.FXMLLoader.access$700(FXMLLoader.java:104) at javafx.fxml.FXMLLoader$ValueElement.processAttribute(FXMLLoader.java:930) at javafx.fxml.FXMLLoader$InstanceDeclarationElement.processAttribute(FXMLLoade r.java:967) at javafx.fxml.FXMLLoader$Element.processStartElement(FXMLLoader.java:216) at javafx.fxml.FXMLLoader$ValueElement.processStartElement(FXMLLoader.java:740) at javafx.fxml.FXMLLoader.processStartElement(FXMLLoader.java:2701) at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2521) at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2435) at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3208) at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3169) at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3142) at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3118) at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3098) at javafx.fxml.FXMLLoader.load(FXMLLoader.java:3091) at application.Main.start(Main.java:21) at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$153(Launch erImpl.java:821) at com.sun.javafx.application.LauncherImpl$$Lambda$51/1596489439.run(Unknown So urce) at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$166(PlatformImpl.j ava:323) at com.sun.javafx.application.PlatformImpl$$Lambda$44/1051754451.run(Unknown So urce) at com.sun.javafx.application.PlatformImpl.lambda$null$164(PlatformImpl.java:29 2) at com.sun.javafx.application.PlatformImpl$$Lambda$47/1001120425.run(Unknown So urce) at java.security.AccessController.doPrivileged(Native Method) at com.sun.javafx.application.PlatformImpl.lambda$runLater$165(PlatformImpl.jav a:291) at com.sun.javafx.application.PlatformImpl$$Lambda$45/1775282465.run(Unknown So urce) 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$141(WinApplication.java:102) at com.sun.glass.ui.win.WinApplication$$Lambda$37/1109371569.run(Unknown Source ) ... 1 more Caused by: java.lang.IllegalAccessException: Class sun.reflect.misc.ReflectUtil can not access a member of class application.Controller with modifiers "" at sun.reflect.Reflection.ensureMemberAccess(Reflection.java:101) at java.lang.Class.newInstance(Class.java:432) at sun.reflect.misc.ReflectUtil.newInstance(ReflectUtil.java:51) at javafx.fxml.FXMLLoader$ValueElement.processAttribute(FXMLLoader.java:923) ... 27 more Exception running application application.Main

RaXenel
  • 1
  • 2
  • 5
  • Besides the errors shown in @eckig's answer, you have one other error I can see: in the controller you define `group` as a `ButtonGroup` (not sure what that is, you didn't show your imports); it should be a `ToggleGroup` as that's how it's defined in the FXML. – James_D Feb 02 '15 at 17:55

1 Answers1

0

There are two issues here:

  1. The constructor of your controller has to be public. See this thread for reference: JavaFX IllegalAccessException during FXML load()
  2. The controller constructor will not work, since you are trying to access a field which is not available at that point.

So for 2. move changelog.setEffect(ds); from the controller to the initialize method.

Community
  • 1
  • 1
eckig
  • 10,964
  • 4
  • 38
  • 52
  • deleted everything about ds effect, this line from constructor and "DropShadow ds = new DropShadow();" still same error, so i think this isnt the problem. but thanks for the tip for the future. – RaXenel Feb 02 '15 at 14:59
  • @RaXenel What error do you get? Any stacktrace for us? – eckig Feb 02 '15 at 15:01
  • added an error, worked perfectly until added few more components to the gui. – RaXenel Feb 02 '15 at 15:09
  • still same, constructor is empty so i think it has no bi g impact on this – RaXenel Feb 02 '15 at 15:36
  • 1
    You get the exact same error message with a `public` constructor? That seems pretty unlikely... – James_D Feb 02 '15 at 15:39
  • yep, public constructor havent solved any errors, but using initialize and that toggleGroup did, thanks everyone, this havent only solved errors, but also tought me few additional things. – RaXenel Feb 02 '15 at 18:24
  • It's actually impossible to get the error you posted if the constructor is public, but I'm glad you figured it out anyway. – James_D Feb 02 '15 at 18:51