Exception in Application start method
Dear Friends,
I am trying to develop javafx programs, here is an unknown exception I got:
ant -f C:\\Users\\haris\\Documents\\NetBeansProjects\\fxlogin jfxsa-run
init:
Deleting: C:\Users\haris\Documents\NetBeansProjects\fxlogin\build\built-jar.properties
deps-jar:
Updating property file: C:\Users\haris\Documents\NetBeansProjects\fxlogin\build\built-jar.properties
compile:
Detected JavaFX Ant API version 1.2
jfx-deployment:
jar:
Copying 12 files to C:\Users\haris\Documents\NetBeansProjects\fxlogin\dist\run993276176
jfx-project-run:
Executing com.javafx.main.Main from C:\Users\haris\Documents\NetBeansProjects\fxlogin\dist\run993276176\fxlogin.jar using platform C:\Program Files\Java\jdk1.7.0_21/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:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at com.javafx.main.Main.launchApp(Main.java:642)
at com.javafx.main.Main.main(Main.java:805)
Caused by: java.lang.RuntimeException: Exception in Application start method
at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:403)
at com.sun.javafx.application.LauncherImpl.access$000(LauncherImpl.java:47)
at com.sun.javafx.application.LauncherImpl$1.run(LauncherImpl.java:115)
at java.lang.Thread.run(Thread.java:722)
Caused by: java.lang.NullPointerException
at fxlogin.Fxlogin.start(Fxlogin.java:70)
at com.sun.javafx.application.LauncherImpl$5.run(LauncherImpl.java:319)
at com.sun.javafx.application.PlatformImpl$5.run(PlatformImpl.java:215)
at com.sun.javafx.application.PlatformImpl$4$1.run(PlatformImpl.java:179)
at com.sun.javafx.application.PlatformImpl$4$1.run(PlatformImpl.java:176)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.application.PlatformImpl$4.run(PlatformImpl.java:176)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.access$100(WinApplication.java:29)
at com.sun.glass.ui.win.WinApplication$3$1.run(WinApplication.java:73)
... 1 more
Java Result: 1
Deleting directory C:\Users\haris\Documents\NetBeansProjects\fxlogin\dist\run993276176
jfxsa-run:
BUILD SUCCESSFUL (total time: 9 seconds)
here is my code
/*
Document : Login
Created on : Jun 7, 2013, 11:11:36 PM
Author : haris
Description:
Purpose of the stylesheet follows.
*/
.root {
display: block;
-fx-background-image: url("background.jpg");
}
java class
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package fxlogin;
import javafx.scene.control.Button;
import javafx.application.Application;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.control.PasswordField;
import javafx.scene.control.TextField;
import javafx.stage.Stage;
import javafx.scene.layout.GridPane ;
import javafx.scene.text.Font;
import javafx.scene.text.FontWeight;
import javafx.scene.text.Text;
import javafx.geometry.Insets;
import javafx.scene.layout.HBox;
/**
*
* @author haris
*/
public class Fxlogin extends Application {
@Override
public void start(Stage primaryStage) {
primaryStage.setTitle("JavaFX Welcome");
GridPane grid = new GridPane();
grid.setAlignment(Pos.CENTER);
grid.setHgap(10);
grid.setVgap(10);
grid.setPadding(new Insets(25, 25, 25, 25));
Text scenetitle = new Text("Welcome");
scenetitle.setFont(Font.font("Tahoma", FontWeight.NORMAL, 20));
grid.add(scenetitle, 0, 0, 2, 1);
Label userName = new Label("User Name:");
grid.add(userName, 0, 1);
TextField userTextField = new TextField();
grid.add(userTextField, 1, 1);
Label pw = new Label("Password:");
grid.add(pw, 0, 2);
PasswordField pwBox = new PasswordField();
grid.add(pwBox, 1, 2);
Button btn = new Button("Sign in");
HBox hbBtn = new HBox(10);
hbBtn.setAlignment(Pos.BOTTOM_RIGHT);
hbBtn.getChildren().add(btn);
grid.add(hbBtn, 1, 4);
final Text actiontarget = new Text();
grid.add(actiontarget, 1, 6);
Scene scene = new Scene(grid, 300, 275);
primaryStage.setScene(scene);
scene.getStylesheets().add(Fxlogin.class.getResource("Login.css").toExternalForm());
primaryStage.show();
}
/**
* The main() method is ignored in correctly deployed JavaFX application.
* main() serves only as fallback in case the application can not be
* launched through deployment artifacts, e.g., in IDEs with limited FX
* support. NetBeans ignores main().
*
* @param args the command line arguments
*/
public static void main(String[] args) {
launch(args);
}
}
Why do I get this exception??? thank you
Edited by: user8709910 on Jun 7, 2013 1:45 PM