Scrollview can host only one direct child although I wrap all in one LinearLayout - android-linearlayout

Following this link: Scrollview can host only one direct child,
I do "Wrap all the children inside of another LinearLayout with wrap_content for both the width and the height and vertical orientation."; however I still get that exception. The following is my layout code:
<ScrollView xmlns:tools="http://schemas.android.com/tools"
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".MainActivity"
tools:ignore="MergeRootFrame">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TextView
android:id="#+id/titleText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/title_text" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TextView
android:id="#+id/appVersionTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="20dp"
android:text="#string/appver_text" />
<TextView
android:id="#+id/libVersionTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/libver_text" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp" >
<Button
android:id="#+id/sensorSelectButton"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="40dp"
android:text="#string/sensor_select_button"
android:textSize="16sp" />
<TextView
android:id="#+id/selectSensorTextView"
android:layout_width="0dip"
android:layout_height="match_parent"
android:layout_weight="0.80"
android:text="#string/select_sensor" />
</LinearLayout>
<TextView
android:id="#+id/bleControlTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/ble_control_title" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="0dp" >
<Button
android:id="#+id/bleConnectButton"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="40dp"
android:text="#string/ble_connect_button"
android:textSize="16sp" />
<Button
android:id="#+id/bleDisconnectButton"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="40dp"
android:text="#string/ble_disconnect_button"
android:textSize="16sp" />
<!--CheckBox
android:id="#+id/fileCheckBox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/file_check_radiobutton" /-->
</LinearLayout>
<Space
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<TextView
android:id="#+id/dataTypeSelectTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:text="#string/datatype_select_title" />
<LinearLayout
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<CheckBox
android:id="#+id/lefthandCheckBox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/lefthand_checkbox"
android:textSize="16sp" />
<CheckBox
android:id="#+id/righthandCheckBox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/righthand_checkbox"
android:textSize="16sp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<CheckBox
android:id="#+id/pdCheckBox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/posture_data_check_box"
android:textSize="16sp" />
<CheckBox
android:id="#+id/tdCheckBox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/transport_data_check_box"
android:textSize="16sp" />
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<CheckBox
android:id="#+id/onDeskCheckBox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="On Desk"
android:textSize="16sp" />
<CheckBox
android:id="#+id/standCheckBox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Stand"
android:textSize="16sp" />
<CheckBox
android:id="#+id/sitCheckBox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Sit"
android:textSize="16sp" />
<CheckBox
android:id="#+id/walkCheckBox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Walking"
android:textSize="16sp" />
<CheckBox
android:id="#+id/runCheckBox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Running"
android:textSize="16sp" />
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<CheckBox
android:id="#+id/vehicleCheckBox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Vehicle"
android:textSize="16sp" />
<CheckBox
android:id="#+id/busCheckBox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Bus"
android:textSize="16sp" />
<CheckBox
android:id="#+id/motoBikeCheckBox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Moto Bike"
android:textSize="16sp" />
<CheckBox
android:id="#+id/cyclingCheckBox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Cycling"
android:textSize="16sp" />
<CheckBox
android:id="#+id/trainCheckBox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Train"
android:textSize="16sp" />
<CheckBox
android:id="#+id/elevatorCheckBox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Elevator"
android:textSize="16sp" />
<CheckBox
android:id="#+id/stairCheckBox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Stair"
android:textSize="16sp" />
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<CheckBox
android:id="#+id/accCheckBox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Acceleration"
android:textSize="16sp" />
<CheckBox
android:id="#+id/prWaveCheckBox"
android:layout_width="124dp"
android:layout_height="wrap_content"
android:text="#string/pressure_wave_data_check_box"
android:textSize="16sp" />
</LinearLayout>
</LinearLayout>
<TextView
android:id="#+id/connectionControlTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:text="#string/connection_control_title" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<Button
android:id="#+id/bleStartButton"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="45dp"
android:text="#string/ble_start_button" />
<Button
android:id="#+id/bleStopButton"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="45dp"
android:text="#string/ble_stop_button" />
<!--Button
android:id="#+id/deviceInfoButton"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="45dp"
android:text="#string/get_device_info_button" />
<Button
android:id="#+id/rawDataButton"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="#string/raw_mode_button_on"
android:textSize="12sp" / -->
</LinearLayout>
<TextView
android:id="#+id/dataViewTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/data_view_title" />
<LinearLayout
android:layout_width="372dp"
android:layout_height="wrap_content"
android:orientation="vertical"
android:baselineAligned="false">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginRight="10dp"
android:layout_weight="0.50"
android:orientation="vertical" >
<TextView
android:id="#+id/pdDataView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/posture_data_view" />
<TextView
android:id="#+id/tdDataView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/transport_data_view" />
<TextView
android:id="#+id/deviceInfoTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/device_info_view_title" />
</LinearLayout>
<LinearLayout
android:layout_width="174dp"
android:layout_height="match_parent"
android:orientation="vertical" >
<TextView
android:id="#+id/accValueDataView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/acc_value_data_view" />
<TextView
android:id="#+id/prWaveDataView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/pressure_wave_data_view" />
<TextView
android:id="#+id/rawDataView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/raw_data_view" />
<com.github.mikephil.charting.charts.LineChart
android:id="#+id/linechart"
android:layout_width="match_parent"
android:layout_height="280dp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TextView
android:id="#+id/featureDataView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/raw_data_view" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</ScrollView>
What is the bug here?

it seems related to ScrollView properties.
The following code works:
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
android:layout_height="match_parent" android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
android:paddingBottom="#dimen/activity_vertical_margin" tools:context=".MainActivity">

Related

NullPointerException when moving ImageView in Javafx, scenebuilder

I'm aware that similar questions have been asked on Stackoverflow before, but none of the answers I've found seem to fix my problem. Also I'd like to add that I'm entirely new to javafx and started coding java literally a week ago altogether, so I apologize for any silly errors in my code!
When trying to move an ImageView in my javafx, moving a player and crates around in the game "sokoban", I get a nullpointerexception stating that my ImageView, marked with an fx:id in scene builder and then called on in my controller class, is a null object. Here's my code:
Application:
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Scene;
import javafx.stage.Stage;
public class App extends Application{
#Override
public void start(final Stage primaryStage) throws Exception {
primaryStage.setTitle("Sokoban");
primaryStage.setScene(new Scene(FXMLLoader.load(App.class.getResource("StartScreen.fxml"))));
primaryStage.show();
}
public static void main(final String[] args) {
App.launch(args);
}
}
Controller:
import java.io.IOException;
import java.util.Arrays;
import java.util.List;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.scene.Scene;
import javafx.scene.Node;
import javafx.scene.control.Button;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.input.KeyCode;
import javafx.scene.input.KeyEvent;
import javafx.scene.layout.AnchorPane;
import javafx.scene.transform.Translate;
import javafx.stage.Stage;
public class SokobanController {
GameState currentGame;
int stepSize;
#FXML Button Easy;
#FXML Button Medium;
#FXML Button Hard;
#FXML AnchorPane easyGameScene;
#FXML AnchorPane mediumGameScene;
#FXML AnchorPane hardGameScene;
#FXML ImageView playerEasy;
#FXML ImageView crateEasy0;
#FXML ImageView crateEasy1;
#FXML ImageView crateEasy2;
#FXML ImageView crateEasy3;
List<ImageView> crateImagesEasy =
Arrays.asList(crateEasy0,crateEasy1,crateEasy2,crateEasy3);
#FXML void handleDifficultySelection(ActionEvent event) throws IOException {
String difficulty = ((Button) event.getSource()).getId();
System.out.println(difficulty);
if (difficulty.equals("Easy")) {
stepSize = 75;
}
else if (difficulty.equals("Medium")) {
}
else if (difficulty.equals("Hard")) {
}
currentGame = new GameState(difficulty);
// playerEasy = new ImageView(new Image("#player.png"));
Scene gameScene = new Scene(FXMLLoader.load(getClass().getResource("GameScreen.fxml")));
gameScene.setOnKeyPressed(new EventHandler<KeyEvent>() {
#Override
public void handle(KeyEvent event) {
handleOnKeyPressed(event);
}
});
Stage window = (Stage)((Node)event.getSource()).getScene().getWindow();
window.setScene(gameScene);
window.show();
}
#FXML void handleOnkey(ActionEvent event) {
System.out.println("hallo");
}
void handleOnKeyPressed(KeyEvent event) {
System.out.println("hallo");
if (event.getCode().equals(KeyCode.LEFT)) {
// Translate translate = new Translate();
// translate.setX(-stepSize);
if (!currentGame.checkCollideWall(-1, 0)) {
int i = 0;
for (Crate crate : currentGame.crates) {
if (currentGame.checkCollideCrate(crate, -1, 0)
&& !currentGame.checkCollideWall(-2, 0)) {
// crateImagesEasy.get(currentGame.crates.indexOf(crate))
// .getTransforms().addAll(translate);
crateImagesEasy.get(currentGame.crates.indexOf(crate)).relocate(-stepSize,0);
// playerEasy.getTransforms().addAll(translate);
i = 1;
playerEasy.relocate(-stepSize, 0);
}
}
if (i == 0) {
// playerEasy.getTransforms().addAll(translate);
playerEasy.relocate(-stepSize, 0);
}
}
}
else if (event.getCode().equals(KeyCode.RIGHT)) {
Translate translate = new Translate();
translate.setX(stepSize);
if (!currentGame.checkCollideWall(1, 0)) {
int i = 0;
for (Crate crate : currentGame.crates) {
if (currentGame.checkCollideCrate(crate, 1, 0)
&& !currentGame.checkCollideWall(2, 0)) {
crateImagesEasy.get(currentGame.crates.indexOf(crate))
.getTransforms().addAll(translate);
playerEasy.getTransforms().addAll(translate);
i = 1;
}
}
if (i == 0) {
playerEasy.getTransforms().addAll(translate);
}
}
}
else if (event.getCode().equals(KeyCode.UP)) {
Translate translate = new Translate();
translate.setY(-stepSize);
if (!currentGame.checkCollideWall(0, -1)) {
int i = 0;
for (Crate crate : currentGame.crates) {
if (currentGame.checkCollideCrate(crate, 0, -1)
&& !currentGame.checkCollideWall(0, -2)) {
crateImagesEasy.get(currentGame.crates.indexOf(crate))
.getTransforms().addAll(translate);
playerEasy.getTransforms().addAll(translate);
i = 1;
}
}
if (i == 0) {
playerEasy.getTransforms().addAll(translate);
}
}
}
else if (event.getCode().equals(KeyCode.DOWN)) {
Translate translate = new Translate();
translate.setY(stepSize);
if (!currentGame.checkCollideWall(0, 1)) {
int i = 0;
for (Crate crate : currentGame.crates) {
if (currentGame.checkCollideCrate(crate, 0, 1)
&& !currentGame.checkCollideWall(0, 2)) {
crateImagesEasy.get(currentGame.crates.indexOf(crate))
.getTransforms().addAll(translate);
playerEasy.getTransforms().addAll(translate);
i = 1;
}
}
if (i == 0) {
playerEasy.getTransforms().addAll(translate);
}
}
}
}
}
FXML-file:
<?import javafx.scene.image.Image?>
<?import javafx.scene.image.ImageView?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.layout.HBox?>
<?import javafx.scene.layout.StackPane?>
<?import javafx.scene.layout.VBox?>
<?import javafx.scene.shape.Circle?>
<?import javafx.scene.shape.Rectangle?>
<?import javafx.scene.text.Font?>
<?import javafx.scene.text.Text?>
<AnchorPane prefHeight="630.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/11.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="app.SokobanController">
<children>
<VBox prefHeight="630.0" prefWidth="600.0">
<children>
<StackPane prefHeight="600.0" prefWidth="600.0">
<children>
<AnchorPane fx:id="easyGameScene" prefHeight="600.0" prefWidth="600.0" style="-fx-background-color: f3e1bb;">
<children>
<ImageView fitHeight="75.0" fitWidth="75.0" pickOnBounds="true" translateX="150.0">
<image>
<Image url="#wall.PNG" />
</image>
</ImageView>
<ImageView fitHeight="75.0" fitWidth="75.0" layoutX="150.0" layoutY="150.0" pickOnBounds="true">
<image>
<Image url="#wall.PNG" />
</image>
</ImageView>
<ImageView fitHeight="75.0" fitWidth="75.0" layoutX="150.0" layoutY="225.0" pickOnBounds="true">
<image>
<Image url="#wall.PNG" />
</image>
</ImageView>
<ImageView fitHeight="75.0" fitWidth="75.0" layoutY="225.0" pickOnBounds="true">
<image>
<Image url="#wall.PNG" />
</image>
</ImageView>
<ImageView fitHeight="75.0" fitWidth="75.0" layoutY="300.0" pickOnBounds="true">
<image>
<Image url="#wall.PNG" />
</image>
</ImageView>
<ImageView fitHeight="75.0" fitWidth="75.0" layoutY="375.0" pickOnBounds="true">
<image>
<Image url="#wall.PNG" />
</image>
</ImageView>
<ImageView fitHeight="75.0" fitWidth="75.0" layoutX="75.0" layoutY="225.0" pickOnBounds="true">
<image>
<Image url="#wall.PNG" />
</image>
</ImageView>
<ImageView fitHeight="75.0" fitWidth="75.0" layoutX="150.0" layoutY="75.0" pickOnBounds="true">
<image>
<Image url="#wall.PNG" />
</image>
</ImageView>
<ImageView fitHeight="75.0" fitWidth="75.0" layoutX="225.0" pickOnBounds="true">
<image>
<Image url="#wall.PNG" />
</image>
</ImageView>
<ImageView fitHeight="75.0" fitWidth="75.0" layoutX="300.0" pickOnBounds="true">
<image>
<Image url="#wall.PNG" />
</image>
</ImageView>
<ImageView fitHeight="75.0" fitWidth="75.0" layoutX="300.0" layoutY="75.0" pickOnBounds="true">
<image>
<Image url="#wall.PNG" />
</image>
</ImageView>
<ImageView fitHeight="75.0" fitWidth="75.0" layoutX="300.0" layoutY="150.0" pickOnBounds="true">
<image>
<Image url="#wall.PNG" />
</image>
</ImageView>
<ImageView fitHeight="75.0" fitWidth="75.0" layoutX="375.0" layoutY="150.0" pickOnBounds="true">
<image>
<Image url="#wall.PNG" />
</image>
</ImageView>
<ImageView fitHeight="75.0" fitWidth="75.0" layoutX="450.0" layoutY="150.0" pickOnBounds="true">
<image>
<Image url="#wall.PNG" />
</image>
</ImageView>
<ImageView fitHeight="75.0" fitWidth="75.0" layoutX="525.0" layoutY="150.0" pickOnBounds="true">
<image>
<Image url="#wall.PNG" />
</image>
</ImageView>
<ImageView fitHeight="75.0" fitWidth="75.0" layoutX="525.0" layoutY="225.0" pickOnBounds="true">
<image>
<Image url="#wall.PNG" />
</image>
</ImageView>
<ImageView fitHeight="75.0" fitWidth="75.0" layoutX="525.0" layoutY="300.0" pickOnBounds="true">
<image>
<Image url="#wall.PNG" />
</image>
</ImageView>
<ImageView fitHeight="75.0" fitWidth="75.0" layoutX="450.0" layoutY="300.0" pickOnBounds="true">
<image>
<Image url="#wall.PNG" />
</image>
</ImageView>
<ImageView fitHeight="75.0" fitWidth="75.0" layoutX="375.0" layoutY="300.0" pickOnBounds="true">
<image>
<Image url="#wall.PNG" />
</image>
</ImageView>
<ImageView fitHeight="75.0" fitWidth="75.0" layoutX="375.0" layoutY="375.0" pickOnBounds="true">
<image>
<Image url="#wall.PNG" />
</image>
</ImageView>
<ImageView fitHeight="75.0" fitWidth="75.0" layoutX="375.0" layoutY="450.0" pickOnBounds="true">
<image>
<Image url="#wall.PNG" />
</image>
</ImageView>
<ImageView fitHeight="75.0" fitWidth="75.0" layoutX="375.0" layoutY="525.0" pickOnBounds="true">
<image>
<Image url="#wall.PNG" />
</image>
</ImageView>
<ImageView fitHeight="75.0" fitWidth="75.0" layoutX="300.0" layoutY="525.0" pickOnBounds="true">
<image>
<Image url="#wall.PNG" />
</image>
</ImageView>
<ImageView fitHeight="75.0" fitWidth="75.0" layoutX="225.0" layoutY="525.0" pickOnBounds="true">
<image>
<Image url="#wall.PNG" />
</image>
</ImageView>
<ImageView fitHeight="75.0" fitWidth="75.0" layoutX="225.0" layoutY="450.0" pickOnBounds="true">
<image>
<Image url="#wall.PNG" />
</image>
</ImageView>
<ImageView fitHeight="75.0" fitWidth="75.0" layoutX="225.0" layoutY="375.0" pickOnBounds="true">
<image>
<Image url="#wall.PNG" />
</image>
</ImageView>
<ImageView fitHeight="75.0" fitWidth="75.0" layoutX="150.0" layoutY="375.0" pickOnBounds="true">
<image>
<Image url="#wall.PNG" />
</image>
</ImageView>
<ImageView fitHeight="75.0" fitWidth="75.0" layoutX="75.0" layoutY="375.0" pickOnBounds="true">
<image>
<Image url="#wall.PNG" />
</image>
</ImageView>
<ImageView fx:id="crateEasy0" fitHeight="75.0" fitWidth="75.0" layoutX="225.0" layoutY="225.0" pickOnBounds="true">
<image>
<Image url="#crate.png" />
</image>
</ImageView>
<ImageView fx:id="crateEasy2" fitHeight="75.0" fitWidth="75.0" layoutX="225.0" layoutY="300.0" pickOnBounds="true">
<image>
<Image url="#crate.png" />
</image>
</ImageView>
<ImageView fx:id="crateEasy3" fitHeight="75.0" fitWidth="75.0" layoutX="300.0" layoutY="375.0" pickOnBounds="true">
<image>
<Image url="#crate.png" />
</image>
</ImageView>
<ImageView fx:id="crateEasy1" fitHeight="75.0" fitWidth="75.0" layoutX="375.0" layoutY="225.0" pickOnBounds="true">
<image>
<Image url="#crate.png" />
</image>
</ImageView>
<ImageView fx:id="playerEasy" fitHeight="75.0" fitWidth="75.0" layoutX="300.0" layoutY="300.0" pickOnBounds="true">
<image>
<Image url="#player.png" />
</image>
</ImageView>
<Circle fill="#eb6020" layoutX="113.0" layoutY="338.0" radius="15.0" stroke="BLACK" strokeType="INSIDE" />
<Circle fill="#eb6020" layoutX="263.0" layoutY="113.0" radius="15.0" stroke="BLACK" strokeType="INSIDE" />
<Rectangle arcHeight="5.0" arcWidth="5.0" fill="#f5f5f500" height="75.0" layoutX="75.0" layoutY="300.0" stroke="#eb6020" strokeType="INSIDE" strokeWidth="5.0" width="75.0" />
<Circle fill="#eb6020" layoutX="488.0" layoutY="263.0" radius="15.0" stroke="BLACK" strokeType="INSIDE" />
<Circle fill="#eb6020" layoutX="338.0" layoutY="488.0" radius="15.0" stroke="BLACK" strokeType="INSIDE" />
<Rectangle arcHeight="5.0" arcWidth="5.0" fill="#f5f5f500" height="75.0" layoutX="225.0" layoutY="75.0" stroke="#eb6020" strokeType="INSIDE" strokeWidth="5.0" width="75.0" />
<Rectangle arcHeight="5.0" arcWidth="5.0" fill="#f5f5f500" height="75.0" layoutX="450.0" layoutY="225.0" stroke="#eb6020" strokeType="INSIDE" strokeWidth="5.0" width="75.0" />
<Rectangle arcHeight="5.0" arcWidth="5.0" fill="#f5f5f500" height="75.0" layoutX="300.0" layoutY="451.0" stroke="#eb6020" strokeType="INSIDE" strokeWidth="5.0" width="75.0" />
</children>
</AnchorPane>
</children>
</StackPane>
<HBox alignment="CENTER" prefHeight="30.0" prefWidth="600.0" style="-fx-background-color: #000000;">
<children>
<Text fill="#d79420" strokeType="OUTSIDE" strokeWidth="0.0" text="Controls: move with arrow-keys and press "R" to restart the game">
<font>
<Font name="System Bold" size="15.0" />
</font>
</Text>
</children>
</HBox>
</children>
</VBox>
</children>
</AnchorPane>
My application starts with an initial difficulty selection scene and then switches over to the actual game scene, where I've encountered the problem.
This is the error I get:
Exception in thread "JavaFX Application Thread" java.lang.NullPointerException
at ovinger/app.SokobanController.handleOnKeyPressed(SokobanController.java:97)
at ovinger/app.SokobanController$1.handle(SokobanController.java:64)
at ovinger/app.SokobanController$1.handle(SokobanController.java:1)
at javafx.base/com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:86)
at javafx.base/com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:238)
at javafx.base/com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:191)
at javafx.base/com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:59)
at javafx.base/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58)
at javafx.base/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at javafx.base/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at javafx.base/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at javafx.base/com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74)
at javafx.base/com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:54)
at javafx.base/javafx.event.Event.fireEvent(Event.java:198)
at javafx.graphics/javafx.scene.Scene$KeyHandler.process(Scene.java:4058)
at javafx.graphics/javafx.scene.Scene$KeyHandler.access$1500(Scene.java:4004)
at javafx.graphics/javafx.scene.Scene.processKeyEvent(Scene.java:2121)
at javafx.graphics/javafx.scene.Scene$ScenePeerListener.keyEvent(Scene.java:2595)
at javafx.graphics/com.sun.javafx.tk.quantum.GlassViewEventHandler$KeyEventNotification.run(GlassViewEventHandler.java:217)
at javafx.graphics/com.sun.javafx.tk.quantum.GlassViewEventHandler$KeyEventNotification.run(GlassViewEventHandler.java:149)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:391)
at javafx.graphics/com.sun.javafx.tk.quantum.GlassViewEventHandler.lambda$handleKeyEvent$1(GlassViewEventHandler.java:248)
at javafx.graphics/com.sun.javafx.tk.quantum.QuantumToolkit.runWithoutRenderLock(QuantumToolkit.java:390)
at javafx.graphics/com.sun.javafx.tk.quantum.GlassViewEventHandler.handleKeyEvent(GlassViewEventHandler.java:247)
at javafx.graphics/com.sun.glass.ui.View.handleKeyEvent(View.java:547)
at javafx.graphics/com.sun.glass.ui.View.notifyKey(View.java:971)
at javafx.graphics/com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at javafx.graphics/com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(WinApplication.java:174)
at java.base/java.lang.Thread.run(Thread.java:830)
(Line 97 is the first point in which I try to call a method on the ImageView object playerEasy)

How can I do dynamic layouts in Javafx?

First of all, excuse me if my English is bad, I don't speak English.
So, I'm working with javafx, when I say "dynamic layouts", I refer to the fact that I have my .fxml already programmed with a default structure which it is so.
menu.fxml view
and its code is this
<?xml version="1.0" encoding="UTF-8"?>
<?import com.jfoenix.controls.JFXButton?>
<?import java.lang.String?>
<?import java.net.URL?>
<?import javafx.geometry.Insets?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.image.Image?>
<?import javafx.scene.image.ImageView?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.layout.HBox?>
<?import javafx.scene.layout.VBox?>
<?import javafx.scene.text.Font?>
<AnchorPane prefWidth="356.0" xmlns="http://javafx.com/javafx/11.0.1" xmlns:fx="http://javafx.com/fxml/1">
<children>
<VBox prefHeight="243.0" prefWidth="356.0" spacing="2.0" stylesheets="#../styles/Containers.css" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<children>
<AnchorPane prefHeight="31.0" prefWidth="356.0">
<children>
<HBox prefHeight="35.0" prefWidth="200.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0">
<padding>
<Insets bottom="8.0" top="8.0" />
</padding>
<children>
<ImageView fitHeight="25.0" fitWidth="25.0" pickOnBounds="true" preserveRatio="true">
<HBox.margin>
<Insets left="10.0" />
</HBox.margin>
<image>
<Image url="#../icons/icons8_Calendar_100px.png" />
</image>
</ImageView>
<Label fx:id="lblFecha" prefHeight="31.0" prefWidth="306.0" stylesheets="#../styles/Strings.css" text="---- ----, -----">
<HBox.margin>
<Insets left="15.0" />
</HBox.margin>
<styleClass>
<String fx:value="h4" />
<String fx:value="principal" />
</styleClass>
</Label>
</children>
</HBox>
</children>
</AnchorPane>
<AnchorPane>
<children>
<HBox prefHeight="35.0" prefWidth="200.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0">
<children>
<ImageView fitHeight="25.0" fitWidth="25.0" pickOnBounds="true" preserveRatio="true">
<image>
<Image url="#../icons/icons8_Clock_100px.png" />
</image>
<HBox.margin>
<Insets left="10.0" />
</HBox.margin>
</ImageView>
<Label fx:id="lblHora" prefHeight="31.0" prefWidth="306.0" stylesheets="#../styles/Strings.css" text="-- : -- : -- --">
<HBox.margin>
<Insets left="15.0" />
</HBox.margin>
<styleClass>
<String fx:value="h4" />
<String fx:value="principal" />
</styleClass>
</Label>
</children>
<padding>
<Insets bottom="8.0" top="8.0" />
</padding>
</HBox>
</children>
</AnchorPane>
<AnchorPane fx:id="opcParlking">
<children>
<JFXButton alignment="BASELINE_LEFT" graphicTextGap="25.0" onAction="#openParking" prefHeight="35.0" prefWidth="366.0" styleClass="h4" text="Parking" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0">
<graphic>
<ImageView fitHeight="25.0" fitWidth="25.0" pickOnBounds="true" preserveRatio="true" translateX="10.0">
<image>
<Image url="#../icons/icons8_Tollbooth_100px.png" />
</image>
</ImageView>
</graphic>
<font>
<Font name="System Bold" size="12.0" />
</font>
<padding>
<Insets bottom="8.0" top="8.0" />
</padding>
<stylesheets>
<URL value="#../styles/Buttons.css" />
<URL value="#../styles/Strings.css" />
</stylesheets>
</JFXButton>
</children>
</AnchorPane>
<AnchorPane>
<children>
<JFXButton alignment="BASELINE_LEFT" graphicTextGap="25.0" prefHeight="35.0" prefWidth="363.0" styleClass="h4" text="Tipo de vehiculos" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0">
<graphic>
<ImageView fitHeight="25.0" fitWidth="25.0" pickOnBounds="true" preserveRatio="true" translateX="10.0">
<image>
<Image url="#../icons/icons8_Traffic_Jam_96px.png" />
</image>
</ImageView>
</graphic>
<font>
<Font name="System Bold" size="12.0" />
</font>
<padding>
<Insets bottom="8.0" top="8.0" />
</padding>
<stylesheets>
<URL value="#../styles/Buttons.css" />
<URL value="#../styles/Strings.css" />
</stylesheets>
</JFXButton>
</children>
</AnchorPane>
<AnchorPane>
<children>
<JFXButton alignment="BASELINE_LEFT" graphicTextGap="25.0" prefHeight="35.0" prefWidth="363.0" styleClass="h4" text="Usuarios" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0">
<graphic>
<ImageView fitHeight="25.0" fitWidth="25.0" pickOnBounds="true" preserveRatio="true" translateX="10.0">
<image>
<Image url="#../icons/icons8_User_Groups_100px.png" />
</image>
</ImageView>
</graphic>
<font>
<Font name="System Bold" size="12.0" />
</font>
<padding>
<Insets bottom="8.0" top="8.0" />
</padding>
<stylesheets>
<URL value="#../styles/Buttons.css" />
<URL value="#../styles/Strings.css" />
</stylesheets>
</JFXButton>
</children>
</AnchorPane>
<AnchorPane>
<children>
<JFXButton alignment="BASELINE_LEFT" graphicTextGap="25.0" prefHeight="35.0" prefWidth="361.0" styleClass="h4" text="Clientes" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0">
<graphic>
<ImageView fitHeight="25.0" fitWidth="25.0" pickOnBounds="true" preserveRatio="true" translateX="10.0">
<image>
<Image url="#../icons/icons8_Helping_Hand_104px.png" />
</image>
</ImageView>
</graphic>
<font>
<Font name="System Bold" size="12.0" />
</font>
<padding>
<Insets bottom="8.0" top="8.0" />
</padding>
<stylesheets>
<URL value="#../styles/Buttons.css" />
<URL value="#../styles/Strings.css" />
</stylesheets>
</JFXButton>
</children>
</AnchorPane>
<AnchorPane>
<children>
<JFXButton alignment="BASELINE_LEFT" graphicTextGap="25.0" prefHeight="35.0" prefWidth="361.0" styleClass="h4" text="Reportes" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0">
<graphic>
<ImageView fitHeight="25.0" fitWidth="25.0" pickOnBounds="true" preserveRatio="true" translateX="10.0">
<image>
<Image url="#../icons/icons8_Combo_Chart_104px.png" />
</image>
</ImageView>
</graphic>
<font>
<Font name="System Bold" size="12.0" />
</font>
<padding>
<Insets bottom="8.0" top="8.0" />
</padding>
<stylesheets>
<URL value="#../styles/Buttons.css" />
<URL value="#../styles/Strings.css" />
</stylesheets>
</JFXButton>
</children>
</AnchorPane>
<AnchorPane>
<children>
<JFXButton alignment="BASELINE_LEFT" graphicTextGap="25.0" prefHeight="29.0" prefWidth="356.0" styleClass="h4" text="Configuraciones" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0">
<graphic>
<ImageView fitHeight="25.0" fitWidth="25.0" pickOnBounds="true" preserveRatio="true" translateX="10.0">
<image>
<Image url="#../icons/icons8_Automation_100px.png" />
</image>
</ImageView>
</graphic>
<font>
<Font name="System Bold" size="12.0" />
</font>
<padding>
<Insets bottom="8.0" top="8.0" />
</padding>
<stylesheets>
<URL value="#../styles/Buttons.css" />
<URL value="#../styles/Strings.css" />
</stylesheets>
</JFXButton>
</children>
</AnchorPane>
</children>
</VBox>
</children>
</AnchorPane>
I want to be able in my execution time to hide any buttons and that the buttons adjust automatically filling the blank space that the hidden button leaves.
I've tried using in the MenuController.java instructions like opcParlking.setVisible(false) but it leave me a blank space. This the picture imagen 2.
How can I fix this?
You will want to assign an fx:id to your VBox as well and then inject it into your controller:
#FXML
private VBox vBox;
Then, in your controller, instead of setting a node visible or not, just remove it from the VBox:
vBox.getChildren().remove(opcParlking);
This will remove the node entirely, instead of just making it invisible. Therefore, you will not have the empty space.

Stylesheet applying in javafx scene builder but not when you run application

So I have a stylesheet with just one style within at the moment for testing purposes.
CSS code:
.minimizeBtn{
-fx-background-color: rgba(0,0,0,1);
}
Setting the ID of the button. This is in the controller for the stage.
public void initialize(URL url, ResourceBundle rb) {
handler = new DbHandlers();
minimizeBtn1.setId("minimizeBtn");
My buttons in fxml:
<Button fx:id="minimizeBtn1" layoutX="520.0" mnemonicParsing="false"
prefHeight="25.0" prefWidth="12.0" styleClass="minimizeBtn" text="Button" />
<Button layoutX="548.0" mnemonicParsing="false" prefHeight="25.0" prefWidth="12.0" styleClass="maximizeBtn" text="Button" />
<Button layoutX="574.0" mnemonicParsing="false" prefHeight="25.0" prefWidth="12.0" styleClass="closeBtn" text="Button" />
The rest of my fxml file:
<AnchorPane prefHeight="450.0" prefWidth="600.0" style="-fx-background-color: #2A7FFF;" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="bownhrmain1.pages.LoginScreenController">
<children>
<AnchorPane prefHeight="450.0" prefWidth="600.0" style="-fx-background-color: #2A7FFF;">
<children>
<Label layoutX="335.0" layoutY="144.0" text="Inventory Systems" textFill="WHITE">
<font>
<Font size="8.0" />
</font>
</Label>
<ImageView fitHeight="150.0" fitWidth="200.0" layoutX="200.0" layoutY="65.0" pickOnBounds="true" preserveRatio="true">
<image>
<Image url="#../images/benx_logo.png" />
</image>
</ImageView>
<Hyperlink layoutX="250.0" layoutY="368.0" text="Forgot Password?" textFill="WHITE" underline="true" />
<JFXButton fx:id="loginBtn" buttonType="RAISED" layoutX="190.0" layoutY="302.0" prefHeight="51.0" prefWidth="221.0" ripplerFill="#2980b9" style="-fx-background-color: #1E5D87;" text="Login" textFill="WHITE" />
<JFXPasswordField fx:id="passwordField" focusColor="#1e5d87" labelFloat="true" layoutX="190.0" layoutY="237.0" prefHeight="34.0" prefWidth="221.0" promptText="Password..." unFocusColor="WHITE" />
<JFXTextField id="text-field" fx:id="usernameField" focusColor="#1e5d87" labelFloat="true" layoutX="190.0" layoutY="176.0" prefHeight="32.0" prefWidth="221.0" promptText="Username/Email..." unFocusColor="WHITE" />
<ImageView fitHeight="20.0" fitWidth="19.0" layoutX="522.0" layoutY="5.0" pickOnBounds="true">
<image>
<Image url="#../images/minimize.png" />
</image>
</ImageView>
<ImageView fitHeight="11.0" fitWidth="12.0" layoutX="554.0" layoutY="9.0" pickOnBounds="true">
<image>
<Image url="#../images/expand-button.png" />
</image>
</ImageView>
<ImageView fitHeight="11.0" fitWidth="11.0" layoutX="581.0" layoutY="9.0" pickOnBounds="true">
<image>
<Image url="#../images/closeWindow.png" />
</image>
</ImageView>
<Button fx:id="minimizeBtn1" layoutX="520.0" mnemonicParsing="false" prefHeight="25.0" prefWidth="12.0" styleClass="minimizeBtn" text="Button" />
<Button layoutX="548.0" mnemonicParsing="false" prefHeight="25.0" prefWidth="12.0" styleClass="maximizeBtn" text="Button" />
<Button layoutX="574.0" mnemonicParsing="false" prefHeight="25.0" prefWidth="12.0" styleClass="closeBtn" text="Button" />
</children>
</AnchorPane>
</children>
</AnchorPane>
The reason i have the styleclass on the buttons is because I have tried both setting the css through class name and ID.
Here's an image of the css working in JavaFx scene builder:
CSS Applying in scene builder.
Here's an imagee of it failing to apply when you run the program:
Not applying
So the answer to this question is to add the following to your start function:
scene.getStylesheets().add(getClass().getResource("pathtostylesheet").toExternalForm());

How to get an image to fit the size of a gridpane on columnSpan

I have a GridPane that contains data on a single video, and an ImageView inside it with a columnSpan="3".
I want to get the video image to fit the entire first row perfectly when window size is changing. Any ideas?
This is what I've got so far:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.control.*?>
<?import javafx.scene.text.*?>
<?import javafx.geometry.*?>
<?import javafx.scene.image.*?>
<?import javafx.scene.layout.*?>
<GridPane fx:id="videoGP" alignment="CENTER" gridLinesVisible="true" prefHeight="315.0" prefWidth="405.0" GridPane.columnIndex="1" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1">
<columnConstraints>
<ColumnConstraints fillWidth="false" halignment="CENTER" hgrow="ALWAYS" maxWidth="30.0" minWidth="10.0" prefWidth="20.0" />
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
<ColumnConstraints hgrow="SOMETIMES" maxWidth="40.0" minWidth="10.0" prefWidth="100.0" />
</columnConstraints>
<rowConstraints>
<RowConstraints maxHeight="1000.0" minHeight="10.0" percentHeight="80.0" prefHeight="94.0" valignment="CENTER" vgrow="ALWAYS" />
<RowConstraints maxHeight="37.0" minHeight="0.0" percentHeight="10.0" prefHeight="17.0" vgrow="SOMETIMES" />
<RowConstraints maxHeight="31.0" minHeight="10.0" percentHeight="10.0" prefHeight="20.0" vgrow="SOMETIMES" />
</rowConstraints>
<children>
<ImageView fx:id="videoImage" fitHeight="181.0" fitWidth="364.0" pickOnBounds="true" preserveRatio="true" GridPane.columnSpan="3" GridPane.halignment="CENTER" GridPane.hgrow="ALWAYS" GridPane.valignment="CENTER" GridPane.vgrow="ALWAYS" StackPane.alignment="CENTER">
<image>
<Image url="#../ItTakesTimeToBecomeYoung.jpg" />
</image>
<GridPane.margin>
<Insets />
</GridPane.margin>
</ImageView>
<ImageView fitHeight="25.0" fitWidth="25.0" onMouseClicked="#clickInfo" pickOnBounds="true" preserveRatio="true" GridPane.rowIndex="1" GridPane.rowSpan="2">
<image>
<Image url="#../Views/Icons/bn_info_normal.png" />
</image>
<GridPane.margin>
<Insets bottom="4.0" left="4.0" right="4.0" top="4.0" />
</GridPane.margin>
</ImageView>
<Label fx:id="videoName" text="Video Name" GridPane.columnIndex="1" GridPane.rowIndex="1">
<font>
<Font name="System Bold Italic" size="12.0" />
</font>
<padding>
<Insets bottom="4.0" left="4.0" right="4.0" top="4.0" />
</padding>
</Label>
<Label fx:id="artistName" text="Artist Name" GridPane.columnIndex="1" GridPane.rowIndex="2">
<padding>
<Insets bottom="4.0" left="4.0" right="4.0" top="4.0" />
</padding>
</Label>
<Label fx:id="videoDuration" alignment="CENTER_RIGHT" prefHeight="13.0" prefWidth="124.0" text="3:49" GridPane.columnIndex="2" GridPane.rowIndex="1">
<padding>
<Insets bottom="4.0" left="4.0" right="4.0" top="4.0" />
</padding>
</Label>
<ImageView fitHeight="25.0" fitWidth="25.0" onMouseClicked="#clickPlay" pickOnBounds="true" preserveRatio="true" GridPane.columnIndex="1" GridPane.halignment="CENTER" GridPane.hgrow="ALWAYS" GridPane.valignment="CENTER" GridPane.vgrow="ALWAYS">
<image>
<Image url="#../Views/Icons/ic_play.png" />
</image>
</ImageView>
</children>
</GridPane>
ImageViews are not resizeable, but you could use a parent that is resizeable and bind the fitWidth and fitHeight properties to the size of the parent using expression binding:
The following example is just a StackPane that could be used as root of a scene to observe the behaviour when resizing the Stage but the same effects would occur, if the StackPane is resized by a Parent, like GridPane:
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.image.*?>
<?import javafx.scene.layout.*?>
<StackPane fx:id="root" xmlns:fx="http://javafx.com/fxml/1">
<children>
<ImageView fitWidth="${root.width}" fitHeight="${root.height}" preserveRatio="true">
<!-- ^^ bind to size of node with fx:id="root" ^^ -->
<image>
<Image url="http://cdn.sstatic.net/Sites/stackoverflow/company/img/logos/so/so-icon.png?v=c78bd457575a"/>
</image>
</ImageView>
</children>
</StackPane>

Can't run javaFX

It worked just fine and then suddenly i got this error
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.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(Unknown Source)
at com.sun.javafx.application.LauncherImpl.launchApplication(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$147(Unknown Source)
at com.sun.javafx.application.LauncherImpl$$Lambda$48/21122690.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.OutOfMemoryError: Java heap space
at java.nio.HeapByteBuffer.<init>(Unknown Source)
at java.nio.ByteBuffer.allocate(Unknown Source)
at com.sun.javafx.iio.png.PNGImageLoader2.load(Unknown Source)
at com.sun.javafx.iio.ImageStorage.loadAll(Unknown Source)
at com.sun.javafx.iio.ImageStorage.loadAll(Unknown Source)
at com.sun.javafx.tk.quantum.PrismImageLoader2.loadAll(Unknown Source)
at com.sun.javafx.tk.quantum.PrismImageLoader2.<init>(Unknown Source)
at com.sun.javafx.tk.quantum.QuantumToolkit.loadImage(Unknown Source)
at javafx.scene.image.Image.loadImage(Unknown Source)
at javafx.scene.image.Image.initialize(Unknown Source)
at javafx.scene.image.Image.<init>(Unknown Source)
at com.sun.javafx.fxml.builder.JavaFXImageBuilder.build(Unknown Source)
at com.sun.javafx.fxml.builder.JavaFXImageBuilder.build(Unknown Source)
at javafx.fxml.FXMLLoader$ValueElement.processEndElement(Unknown Source)
at javafx.fxml.FXMLLoader.processEndElement(Unknown Source)
at javafx.fxml.FXMLLoader.loadImpl(Unknown Source)
at javafx.fxml.FXMLLoader.loadImpl(Unknown Source)
at javafx.fxml.FXMLLoader.loadImpl(Unknown Source)
at javafx.fxml.FXMLLoader.loadImpl(Unknown Source)
at javafx.fxml.FXMLLoader.loadImpl(Unknown Source)
at javafx.fxml.FXMLLoader.loadImpl(Unknown Source)
at javafx.fxml.FXMLLoader.loadImpl(Unknown Source)
at javafx.fxml.FXMLLoader.load(Unknown Source)
at application.Main.start(Main.java:18)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$153(Unknown Source)
at com.sun.javafx.application.LauncherImpl$$Lambda$51/32359153.run(Unknown Source)
at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$166(Unknown Source)
at com.sun.javafx.application.PlatformImpl$$Lambda$45/11567059.run(Unknown Source)
at com.sun.javafx.application.PlatformImpl.lambda$null$164(Unknown Source)
at com.sun.javafx.application.PlatformImpl$$Lambda$47/4247839.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.application.PlatformImpl.lambda$runLater$165(Unknown Source)
Exception running application application.Main
And it points me to my main class
package application;
import java.net.URL;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;
import connection.Conexiune;
public class Main extends Application {
#Override
public void start(Stage primaryStage) {
try {
Parent root = FXMLLoader.load(getClass().getResource(
"/application/MyView.fxml"));
Scene scene = new Scene(root);
scene.getStylesheets().add(
getClass().getResource("application.css").toExternalForm());
primaryStage.setScene(scene);
primaryStage.setTitle("StarMap v7.5");
primaryStage.show();
setUserAgentStylesheet(STYLESHEET_CASPIAN);
Conexiune.createConnection();
} catch (Exception e) {
e.printStackTrace();
}
}
public static void main(String[] args) {
launch(args);
}
}
more exactly this line i don't know why because it worked fine until now all i did is add another imageview to the interface using scene builder
Parent root = FXMLLoader.load(getClass().getResource("/application/MyView.fxml"));
can anyone please help me?
this is my FXML
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.shape.*?>
<?import javafx.scene.paint.*?>
<?import javafx.scene.text.*?>
<?import javafx.scene.chart.*?>
<?import javafx.scene.image.*?>
<?import javafx.scene.*?>
<?import javafx.scene.effect.*?>
<?import javafx.scene.control.*?>
<?import java.lang.*?>
<?import javafx.scene.layout.*?>
<?import javafx.scene.layout.AnchorPane?>
<AnchorPane fx:id="aPane" centerShape="false" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="800.0" prefWidth="1280.0" scaleShape="false" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="controller.MyController">
<effect>
<Blend />
</effect>
<children>
<Pane fx:id="secPane" prefHeight="800.0" prefWidth="1280.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<children>
<ComboBox fx:id="ora" layoutX="14.0" layoutY="217.0" prefHeight="25.0" prefWidth="174.0" promptText="Selectati ora" visible="false" />
<DatePicker fx:id="data" layoutX="14.0" layoutY="127.0" promptText="Selectati data" />
<Pane fx:id="imgPaneIanuarie" layoutX="200.0" layoutY="14.0" prefHeight="692.0" prefWidth="1066.0" style="-fx-background-color: black;" visible="false">
<children>
<ImageView fx:id="sMap" fitHeight="692.0" fitWidth="1066.0" layoutX="-1.0" pickOnBounds="true" preserveRatio="true" />
<ImageView fx:id="Sirius" fitHeight="16.0" fitWidth="15.0" layoutX="335.0" layoutY="433.0" onMouseClicked="#getInfoSirius" onMouseEntered="#mouseEnteredSirius" pickOnBounds="true" preserveRatio="true">
<image>
<Image url="#../../Img/sirius.png" />
</image>
</ImageView>
<ImageView fx:id="Procyon" fitHeight="12.0" fitWidth="11.0" layoutX="284.0" layoutY="319.0" onMouseClicked="#getInfoProcyon" onMouseEntered="#mouseEnteredProcyon" pickOnBounds="true" preserveRatio="true">
<image>
<Image url="#../../Img/procyon.png" />
</image>
</ImageView>
<ImageView fx:id="Beetlegeuse" fitHeight="13.0" fitWidth="13.0" layoutX="402.0" layoutY="319.0" onMouseClicked="#getInfoBetelgeuse" onMouseEntered="#mouseEnteredBeetlegeuse" pickOnBounds="true" preserveRatio="true">
<image>
<Image url="#../../Img/beetlegeuse.png" />
</image>
</ImageView>
<ImageView fx:id="Rigel" fitHeight="12.0" fitWidth="13.0" layoutX="450.0" layoutY="398.0" onMouseClicked="#getInfoRigel" onMouseEntered="#mouseEnteredRigel" pickOnBounds="true" preserveRatio="true">
<image>
<Image url="#../../Img/rigel.png" />
</image></ImageView>
<ImageView fx:id="Capella" fitHeight="18.0" fitWidth="16.0" layoutX="449.0" layoutY="126.0" onMouseClicked="#getInfoCapella" onMouseEntered="#mouseEnteredCapella" pickOnBounds="true" preserveRatio="true">
<image>
<Image url="#../../Img/capella.png" />
</image>
</ImageView>
<ImageView fx:id="Aldebaran" fitHeight="9.0" fitWidth="10.0" layoutX="497.0" layoutY="281.0" onMouseClicked="#getInfoAldebaran" onMouseEntered="#mouseEnteredAldebaran" pickOnBounds="true" preserveRatio="true">
<image>
<Image url="#../../Img/aldebaran.png" />
</image>
</ImageView>
<ImageView fx:id="Polux" fitHeight="10.0" fitWidth="11.0" layoutX="297.0" layoutY="213.0" onMouseClicked="#getInfoPollux" onMouseEntered="#mouseEnteredPolux" pickOnBounds="true" preserveRatio="true">
<image>
<Image url="#../../Img/polux.png" />
</image>
</ImageView>
<ImageView fx:id="Castor" fitHeight="7.0" fitWidth="6.0" layoutX="314.0" layoutY="199.0" onMouseClicked="#getInfoCastor" onMouseEntered="#mouseEnteredCastor" pickOnBounds="true" preserveRatio="true">
<image>
<Image url="#../../Img/castor.png" />
</image>
</ImageView>
<ImageView fx:id="Regulus" fitHeight="8.0" fitWidth="8.0" layoutX="14.0" layoutY="229.0" onMouseClicked="#getInfoRegulus" onMouseEntered="#mouseEnteredRegulus" pickOnBounds="true" preserveRatio="true">
<image>
<Image url="#../../Img/regulus.png" />
</image>
</ImageView>
<ImageView fx:id="Mirphak" fitHeight="10.0" fitWidth="10.0" layoutX="579.0" layoutY="54.0" onMouseClicked="#getInfoMirfak" onMouseEntered="#mouseEnteredMirphak" pickOnBounds="true" preserveRatio="true">
<image>
<Image url="#../../Img/mirphak.png" />
</image>
</ImageView>
<Label layoutX="511.0" layoutY="6.0" prefHeight="35.0" prefWidth="35.0" text=" N" textAlignment="JUSTIFY" textFill="#fc0f0f">
<font>
<Font name="System Bold" size="22.0" />
</font>
</Label>
<Label layoutX="508.0" layoutY="643.0" prefHeight="35.0" prefWidth="35.0" text=" S" textFill="#fc0f0f">
<font>
<Font name="System Bold" size="22.0" />
</font>
</Label>
<Label layoutX="1017.0" layoutY="338.0" prefHeight="35.0" prefWidth="35.0" text=" W" textFill="#fc0f0f">
<font>
<Font name="System Bold" size="22.0" />
</font>
</Label>
<Label layoutX="14.0" layoutY="329.0" prefHeight="35.0" prefWidth="35.0" text=" E" textFill="#fc0f0f">
<font>
<Font name="System Bold" size="22.0" />
</font>
</Label>
<ImageView fx:id="debug" fitHeight="5.0" fitWidth="5.0" layoutX="487.0" layoutY="438.0" pickOnBounds="true" preserveRatio="true" visible="false">
<image>
<Image url="#../../Img/red.png" />
</image>
</ImageView>
<ImageView fx:id="nodePos1" disable="true" fitHeight="15.0" fitWidth="15.0" layoutX="1027.0" layoutY="653.0" pickOnBounds="true" preserveRatio="true" visible="false">
<image>
<Image url="#../../Img/halo.png" />
</image>
</ImageView>
<ImageView fx:id="nodePos2" disable="true" fitHeight="15.0" fitWidth="15.0" layoutX="964.0" layoutY="658.0" pickOnBounds="true" preserveRatio="true" visible="false">
<image>
<Image url="#../../Img/halo.png" />
</image>
</ImageView>
<ImageView fx:id="nodePos3" disable="true" fitHeight="15.0" fitWidth="15.0" layoutX="1010.0" layoutY="636.0" pickOnBounds="true" preserveRatio="true" visible="false">
<image>
<Image url="#../../Img/halo.png" />
</image>
</ImageView>
<ImageView fx:id="nodePos4" disable="true" fitHeight="15.0" fitWidth="15.0" layoutX="794.0" layoutY="494.0" pickOnBounds="true" preserveRatio="true" visible="false">
<image>
<Image url="#../../Img/halo.png" />
</image>
</ImageView>
<ImageView fx:id="nodePos5" disable="true" fitHeight="15.0" fitWidth="15.0" layoutX="233.0" layoutY="419.0" pickOnBounds="true" preserveRatio="true" visible="false">
<image>
<Image url="#../../Img/halo.png" />
</image>
</ImageView>
<ImageView fx:id="nodePos6" disable="true" fitHeight="15.0" fitWidth="15.0" layoutX="84.0" layoutY="434.0" pickOnBounds="true" preserveRatio="true" visible="false">
<image>
<Image url="#../../Img/halo.png" />
</image>
</ImageView>
<ImageView fx:id="nodePos7" disable="true" fitHeight="15.0" fitWidth="15.0" layoutX="84.0" layoutY="434.0" pickOnBounds="true" preserveRatio="true" visible="false">
<image>
<Image url="#../../Img/halo.png" />
</image>
</ImageView>
<ImageView fx:id="infoSirius" disable="true" fitHeight="100.0" fitWidth="100.0" layoutX="14.0" layoutY="578.0" pickOnBounds="true" preserveRatio="true" visible="false">
<image>
<Image url="#../../Img/blueStar.gif" />
</image>
</ImageView>
<Label fx:id="sNameSirius" contentDisplay="CENTER" disable="true" layoutX="14.0" layoutY="556.0" lineSpacing="5.0" prefHeight="25.0" prefWidth="100.0" text="Sirius" textAlignment="JUSTIFY" textFill="WHITE" underline="true" visible="false">
<font>
<Font name="System Bold" size="20.0" />
</font>
</Label>
<ImageView fx:id="infoBetlegeuse" disable="true" fitHeight="100.0" fitWidth="100.0" layoutX="115.0" layoutY="592.0" pickOnBounds="true" preserveRatio="true" visible="false">
<image>
<Image url="#../../Img/redStar.gif" />
</image>
</ImageView>
<Label fx:id="sNameBetelgeuse" disable="true" layoutX="114.0" layoutY="556.0" prefHeight="30.0" prefWidth="100.0" text="Betlegeuse" textAlignment="CENTER" textFill="WHITE" underline="true" visible="false">
<font>
<Font name="System Bold" size="19.0" />
</font>
</Label>
<ImageView fx:id="infoMirfak" disable="true" fitHeight="100.0" fitWidth="100.0" layoutX="213.0" layoutY="604.0" pickOnBounds="true" preserveRatio="true" visible="false">
<image>
<Image url="#../../Img/mirphakStar.png" />
</image>
</ImageView>
<Label fx:id="sNameMirfak" disable="true" layoutX="219.0" layoutY="556.0" prefHeight="30.0" prefWidth="100.0" text="Mirfak" textFill="WHITE" underline="true" visible="false">
<font>
<Font name="System Bold" size="20.0" />
</font>
</Label>
<ImageView fx:id="infoProcyon" disable="true" fitHeight="100.0" fitWidth="100.0" layoutX="285.0" layoutY="604.0" pickOnBounds="true" preserveRatio="true" visible="false">
<image>
<Image url="#../../Img/mirphakStar.png" />
</image>
</ImageView>
<Label fx:id="sNameProcyon" disable="true" layoutX="284.0" layoutY="556.0" prefHeight="30.0" prefWidth="100.0" text="Procyon" textFill="WHITE" underline="true" visible="false">
<font>
<Font name="System Bold" size="20.0" />
</font>
</Label>
<Label fx:id="sNamePolux" disable="true" layoutX="371.0" layoutY="556.0" prefHeight="30.0" prefWidth="100.0" text="Pollux" textFill="WHITE" underline="true" visible="false">
<font>
<Font name="System Bold" size="20.0" />
</font>
</Label>
<ImageView fx:id="infoPolux" disable="true" fitHeight="100.0" fitWidth="100.0" layoutX="372.0" layoutY="604.0" pickOnBounds="true" preserveRatio="true" visible="false">
<image>
<Image url="#../../Img/poluxStar.png" />
</image>
</ImageView>
<ImageView fx:id="infoCapella" disable="true" fitHeight="100.0" fitWidth="100.0" layoutX="547.0" layoutY="604.0" pickOnBounds="true" preserveRatio="true" visible="false">
<image>
<Image url="#../../Img/capellaStar.png" />
</image>
</ImageView>
<Label fx:id="sNameCapella" disable="true" layoutX="546.0" layoutY="556.0" prefHeight="30.0" prefWidth="100.0" text="Capella" textFill="WHITE" underline="true" visible="false">
<font>
<Font name="System Bold" size="20.0" />
</font>
</Label>
<Label fx:id="sNameRegulus" disable="true" layoutX="628.0" layoutY="556.0" prefHeight="30.0" prefWidth="100.0" text="Regulus" textFill="WHITE" underline="true" visible="false">
<font>
<Font name="System Bold" size="20.0" />
</font>
</Label>
<ImageView fx:id="infoRegulus" disable="true" fitHeight="100.0" fitWidth="100.0" layoutX="629.0" layoutY="604.0" pickOnBounds="true" preserveRatio="true" visible="false">
<image>
<Image url="#../../Img/regulusStar.png" />
</image>
</ImageView>
<ImageView fx:id="infoAldebaran" disable="true" fitHeight="100.0" fitWidth="100.0" layoutX="719.0" layoutY="578.0" pickOnBounds="true" preserveRatio="true" visible="false">
<image>
<Image url="#../../Img/aldebaranstar.gif" />
</image>
</ImageView>
<Label fx:id="sNameAldebaran" disable="true" layoutX="719.0" layoutY="556.0" prefHeight="30.0" prefWidth="100.0" text="Aldebaran" textFill="WHITE" underline="true" visible="false">
<font>
<Font name="System Bold" size="20.0" />
</font>
</Label>
<ImageView fx:id="infoRigel" disable="true" fitHeight="100.0" fitWidth="100.0" layoutX="838.0" layoutY="604.0" pickOnBounds="true" preserveRatio="true" visible="false">
<image>
<Image url="#../../Img/rigeStar.png" />
</image>
</ImageView>
<Label fx:id="sNameRigel" disable="true" layoutX="837.0" layoutY="556.0" prefHeight="30.0" prefWidth="100.0" text="Rigel" textFill="WHITE" underline="true" visible="false">
<font>
<Font name="System Bold" size="20.0" />
</font>
</Label>
<ImageView fx:id="infoCastor" disable="true" fitHeight="100.0" fitWidth="100.0" layoutX="952.0" layoutY="604.0" pickOnBounds="true" preserveRatio="true" visible="false">
<image>
<Image url="#../../Img/castorStar.png" />
</image>
</ImageView>
<font>
<Font name="System Bold" size="20.0" />
</font>
</Label>
</children></Pane>
</children>
</Pane>
</children>
</AnchorPane>

Resources