Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search Coderanch
Advance search
Google search
Register / Login
kevin flint
Greenhorn
+ Follow
news
3
Posts
1
Threads
since May 05, 2012
Merit badge:
grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads
Recent posts by kevin flint
Adding CSS produces error
I got it working now. I just rebuilt the project. Weird.
show more
12 years ago
JavaFX
Adding CSS produces error
I tried doing it like this
Scene scene = new Scene(grid, 300, 275); primaryStage.setScene(scene); scene.getStylesheets().add("style.css"); primaryStage.show();
I saved the main file and the css file in the same package.
Got this new error.
WARNING: com.sun.javafx.css.StyleManager loadStylesheetUnPrivileged Resource "style.css" not found.
show more
12 years ago
JavaFX
Adding CSS produces error
Hi, I'm new to JavaFX.
I just started doing
this
.
^ How I arranged my files.
Here's the code:
/* * To change this template, choose Tools | Templates * and open the template in the editor. */ import javafx.application.Application; import javafx.event.ActionEvent; import javafx.event.EventHandler; import javafx.geometry.Insets; import javafx.geometry.Pos; import javafx.scene.Scene; import javafx.scene.control.Button; import javafx.scene.control.Label; import javafx.scene.control.PasswordField; import javafx.scene.control.TextField; import javafx.scene.layout.GridPane; import javafx.scene.layout.HBox; import javafx.scene.paint.Color; import javafx.scene.text.Font; import javafx.scene.text.FontWeight; import javafx.scene.text.Text; import javafx.stage.Stage; /** * * @author Administrator */ public class LoginTest extends Application { /** * @param args the command line arguments */ public static void main(String[] args) { launch(args); } @Override public void start(Stage primaryStage) { primaryStage.setTitle("Sample Login Form"); 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("Arial", FontWeight.NORMAL, 24)); grid.add(sceneTitle, 0, 0, 2, 1); Label usernameLabel = new Label("Username:"); grid.add(usernameLabel, 0, 1); final TextField usernameTextField = new TextField(); grid.add(usernameTextField, 1, 1); Label passwordLabel = new Label("Password:"); grid.add(passwordLabel, 0, 2); final PasswordField passwordField = new PasswordField(); grid.add(passwordField, 1, 2); Button button = new Button("Login"); HBox hbButton = new HBox(); hbButton.setAlignment(Pos.BOTTOM_RIGHT); hbButton.getChildren().add(button); grid.add(hbButton, 1, 4); final Text loginMessageStatus = new Text(); grid.add(loginMessageStatus, 1, 5); button.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent e) { if (usernameTextField.getText().equals("demo") && passwordField.getText().equals("demo")) { loginMessageStatus.setFill(Color.GREEN); loginMessageStatus.setText("Username and Password is correct."); } else { loginMessageStatus.setFill(Color.RED); loginMessageStatus.setText("Username or Password is incorrect, kindly recheck."); } } }); Scene scene = new Scene(grid, 300, 275); primaryStage.setScene(scene); scene.getStylesheets().add(LoginTest.class.getResource("LoginStyle.css").toExternalForm()); primaryStage.show(); } }
I don't know where I went wrong, but here's the error.
Exception in Application start method Exception in thread "main" java.lang.RuntimeException: Exception in Application start method at com.sun.javafx.application.LauncherImpl.launchApplication1(Unknown Source) at com.sun.javafx.application.LauncherImpl.access$000(Unknown Source) at com.sun.javafx.application.LauncherImpl$1.run(Unknown Source) at java.lang.Thread.run(Thread.java:722) Caused by: java.lang.NullPointerException at LoginTest.start(LoginTest.java:89) at com.sun.javafx.application.LauncherImpl$5.run(Unknown Source) at com.sun.javafx.application.PlatformImpl$4.run(Unknown Source) at com.sun.javafx.application.PlatformImpl$3.run(Unknown Source) at com.sun.glass.ui.win.WinApplication._runLoop(Native Method) at com.sun.glass.ui.win.WinApplication.access$100(Unknown Source) at com.sun.glass.ui.win.WinApplication$2$1.run(Unknown Source) ... 1 more Java Result: 1
My CSS code:
root { display: block; } .root { -fx-background-image: url("background.jpg"); }
Where did I go wrong?
show more
12 years ago
JavaFX