-1

[enter image description here][1]Here is the Driver , The program will run with no errors but the gui will not show up at all. I am a noob to FX and i am just trying to get it to work.

public class Vacation extends Application {
private Stage stage;

 @Override
public void start(Stage stage) throws Exception {
  this.stage = stage;
  try{
    FXMLLoader loader = new 
FXMLLoader(getClass().getResource("Vacation.fxml"));
    AnchorPane pane = loader.load();

    MainControler mainController = loader.getController();
    Scene scene = new Scene(pane, 640, 450);
    stage.setScene(scene);
    stage.show();

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

    }
}

Here is the FXML.

<AnchorPane id="AnchorPane" prefHeight="400.0" prefWidth="600.0" xmlns:fx="http://javafx.com/fxml/1" xmlns="http://javafx.com/javafx/8.0.141" fx:controller="Application.MainControler">
<children>
  <AnchorPane layoutX="9.0" layoutY="8.0" prefHeight="131.0" prefWidth="572.0" style="-fx-background-color: #333333;">
     <children>
        <ImageView fitHeight="106.0" fitWidth="470.0" layoutX="51.0" layoutY="13.0">
           <image>
              <Image url="@../../../../../Desktop/FxPics/dc3.jpg" />
           </image>
        </ImageView>
        <Button fx:id="DC" layoutX="229.0" layoutY="53.0" mnemonicParsing="false" onAction="#DCbuttonPpess" text="Devils CourtHouse" textFill="#ee0707" />
     </children>
  </AnchorPane>
  <AnchorPane layoutX="9.0" layoutY="149.0" prefHeight="131.0" prefWidth="572.0" style="-fx-background-color: #333333;">
     <children>
        <ImageView fitHeight="100.0" fitWidth="476.0" layoutX="49.0" layoutY="17.0">
           <image>
              <Image url="@../../../../../Desktop/FxPics/reef.jpg" />
           </image>
        </ImageView>
        <Button fx:id="STB" layoutX="226.0" layoutY="55.0" mnemonicParsing="false" onAction="#STBbuttonPress" text="Scuba The Bahamas" textFill="#01d3f8" />
     </children>
  </AnchorPane>
  <AnchorPane layoutX="9.0" layoutY="295.0" prefHeight="131.0" prefWidth="572.0" style="-fx-background-color: #333333;">
     <children>
        <ImageView fitHeight="100.0" fitWidth="488.0" layoutX="42.0" layoutY="16.0">
           <image>
              <Image url="@../../../../../Desktop/FxPics/SD2.jpg" />
           </image>
        </ImageView>
        <Button fx:id="SDC" layoutX="230.0" layoutY="53.0" mnemonicParsing="false" onAction="#SDCButtonPress" text="Sky Dive Colorado" textFill="#ffa616" />
     </children>
  </AnchorPane>
  <AnchorPane layoutX="9.0" layoutY="445.0" prefHeight="131.0" prefWidth="572.0" style="-fx-background-color: #333333;">
     <children>
        <ImageView fitHeight="106.0" fitWidth="488.0" layoutX="42.0" layoutY="13.0">
           <image>
              <Image url="@../../../../../Desktop/FxPics/c3.jpg" />
           </image>
        </ImageView>
        <Button fx:id="BC" layoutX="248.0" layoutY="54.0" mnemonicParsing="false" onAction="#BCButtonpress" text="Baron Cliffs" textFill="#543801" />
     </children>
  </AnchorPane>

and here is the Controller.

public class MainControler implements Initializable {

     @FXML
   private Button DC;

    @FXML
    private Button STB;

    @FXML
    private Button SDC;

    @FXML
    private Button BC;


   @FXML public void BCButtonpress(ActionEvent event) {
try{
    FXMLLoader bcLoader = new 
FXMLLoader(getClass().getResource("BaronCliff.fxml"));
    Parent root1 = (Parent) bcLoader.load();
    Stage bc = new Stage();
    bc.setTitle("Baron Cliff");
    bc.setScene(new Scene(root1));
    bc.show();

}catch (IOException e){
    System.out.println("Cant Load new Window.");
}
}


  @FXML  public void DCbuttonpress(ActionEvent event) {
try{
    FXMLLoader bcLoader = new 
FXMLLoader(getClass().getResource("DevilsCourthouse.fxml"));
    Parent root1 = (Parent) bcLoader.load();
    Stage bc = new Stage();
    bc.setTitle("Devils Courthouse");
    bc.setScene(new Scene(root1));
    bc.show();

}catch (IOException e){
    System.out.println("Cant Load new Window.");
}
}


  @FXML  public void STBbuttonPress(ActionEvent event) {
 try{
    FXMLLoader bcLoader = new 
    FXMLLoader(getClass().getResource("Scuba.fxml"));
    Parent root1 = (Parent) bcLoader.load();
    Stage bc = new Stage();
    bc.setTitle("Scuba the Bahamas");
    bc.setScene(new Scene(root1));
    bc.show();

}catch (Exception e){
    System.out.println("Cant Load new Window.");
}
}


    @FXML public void SDC(ActionEvent event) {
 try{
   FXMLLoader bcLoader = new 
 FXMLLoader(getClass().getResource("Skydive.fxml"));
   Parent root1 = (Parent) bcLoader.load();
   Stage bc = new Stage();
   bc.setTitle("Skydive Colorado");
   bc.setScene(new Scene(root1));
   bc.show();

  }catch (Exception e){
   System.out.println("Cant Load new Window.");
   }
    }

Thanks in advance for any help, I finally broke down and decided to post this, i could not find anyone with my problem probably something minor but i have no one with fresh eyes to really give it a look. apologies.

After putting in the e.printStackTrace(); in the catch block I got a list of exceptions.

  javafx.fxml.LoadException: Error resolving 
                   onAction='#DCbuttonPpess', either the event handler is 
                not in the Namespace or there is an error in the script.

       file:/C:/Users/Kalamar/Documents/NetBeansProjects/Vacation/di 
           st/run201542084/Vacation.jar!/Application/Vacation.fxml:17

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.load(FXMLLoader.java:2409)
at Application.Vacation.start(Vacation.java:27)
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)
at java.lang.Thread.run(Thread.java:748)

here is the typo fixed.

<Button fx:id="DC" layoutX="229.0" layoutY="53.0" mnemonicParsing="false" 
 onAction="#DCbuttonpress" text="Devils CourtHouse" textFill="#ee0707" 
 />enter 

here is the exception after running after the fix.

            Executing C:\Users\Kalamar\Documen      
           ts\NetBeansProjects\Vacation\dist  \run1238622098\Vacation 
        .jar using platform C:\Program Files\Java\jdk1.8.0_151\jre/bin/java
       javafx.fxml.LoadException: Error resolving onAction='#DCbuttonpress', 
        either the event handler is not in the Namespace or there is an 
         error in the script 
                file:/C:/Users/Kalamar/Documents/NetBeansProjects/Vacation/d 
               ist/run1238622098/V acation.jar!/Application/Vacation.fxml:17

1 Answers1

0

The stack trace:

javafx.fxml.LoadException: Error resolving 
               onAction='#DCbuttonPpess', either the event handler is 
            not in the Namespace or there is an error in the script.

   file:/C:/Users/Kalamar/Documents/NetBeansProjects/Vacation/di 
       st/run201542084/Vacation.jar!/Application/Vacation.fxml:17

Indicates that there is a problem with the onAction handler specified at line 17 of the Vacation.fxml file. That line is:

<Button fx:id="DC" ... onAction="#DCbuttonPpess" ... />

There is a clear typo in the onAction attribute: the method defined in the controller class is

@FXML public void DCbuttonpress(ActionEvent event) {
    /* ... */
}

So the FXML should be

<Button fx:id="DC" ... onAction="#DCbuttonpress" ... />
James_D
  • 201,275
  • 16
  • 291
  • 322