Is there a concept of growth priority in javafx? - css

How does JavaFX renderer decides which component grows when pref sizes sum of 2 components is lower than the overall scene size ?
Is there any way to decide which component should grow first and how more than the other component as flexbox does in regular css ?
here is a css code that describes what i want to do in my javafx app :
.my-container {
display: flex;
width: 1400px;
}
.my-component-1 {
/*pref width is 800*/
flex: 2;
}
.my-component-2 {
/*pref width is 300*/
flex: 1;
}
for example, in the above case, component 1 will grow up to 1000px and component 2 up to 400px.
what is the javafx equivalent to the flex property ?

Here is a small example how a GridPane layout with "Percent Width" works:
Preview:
Controller Class:
package sample;
import javafx.beans.property.DoubleProperty;
import javafx.beans.property.SimpleDoubleProperty;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.Label;
import javafx.scene.layout.Pane;
import javafx.stage.Stage;
import java.net.URL;
import java.util.ResourceBundle;
public class WidthController implements Initializable {
#FXML
private Pane
redPane,
bluePane;
#FXML
private Label
stageWidthLabel,
redPaneWidthLabel,
bluePaneWidthLabel;
private DoubleProperty
stageWidth = new SimpleDoubleProperty(),
redPaneWidth = new SimpleDoubleProperty(),
bluePaneWidth = new SimpleDoubleProperty();
#Override
public void initialize(URL location, ResourceBundle resources) {
stageWidthLabel.textProperty().bind(stageWidth.asString());
redPaneWidthLabel.textProperty().bind(redPaneWidth.asString());
bluePaneWidthLabel.textProperty().bind(bluePaneWidth.asString());
redPaneWidth.bind(redPane.widthProperty());
bluePaneWidth.bind(bluePane.widthProperty());
}
public void setStage(Stage stage) {
stageWidth.bind(stage.widthProperty());
}
}
FXML File:
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.geometry.Insets?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.layout.ColumnConstraints?>
<?import javafx.scene.layout.GridPane?>
<?import javafx.scene.layout.Pane?>
<?import javafx.scene.layout.RowConstraints?>
<GridPane prefHeight="400.0" prefWidth="1100.0" xmlns="http://javafx.com/javafx/11.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="sample.WidthController">
<columnConstraints>
<ColumnConstraints hgrow="SOMETIMES" percentWidth="72.73" />
<ColumnConstraints hgrow="SOMETIMES" percentWidth="27.27" />
</columnConstraints>
<rowConstraints>
<RowConstraints vgrow="SOMETIMES" />
<RowConstraints vgrow="NEVER" />
</rowConstraints>
<children>
<Pane fx:id="bluePane" style="-fx-background-color: blue;" />
<Pane fx:id="redPane" style="-fx-background-color: red;" GridPane.columnIndex="1" />
<GridPane hgap="3.0" vgap="3.0" GridPane.columnSpan="2" GridPane.rowIndex="1">
<columnConstraints>
<ColumnConstraints fillWidth="false" halignment="RIGHT" hgrow="NEVER" />
<ColumnConstraints fillWidth="false" halignment="LEFT" hgrow="NEVER" minWidth="10.0" />
</columnConstraints>
<rowConstraints>
<RowConstraints fillHeight="false" valignment="CENTER" vgrow="NEVER" />
<RowConstraints fillHeight="false" valignment="CENTER" vgrow="NEVER" />
<RowConstraints fillHeight="false" valignment="CENTER" vgrow="NEVER" />
<RowConstraints fillHeight="false" valignment="CENTER" vgrow="NEVER" />
</rowConstraints>
<children>
<Label text="Width information" underline="true" />
<Label text="Stage:" GridPane.rowIndex="1" />
<Label text="Blue Pane:" GridPane.rowIndex="2" />
<Label text="Red Pane:" GridPane.rowIndex="3" />
<Label fx:id="stageWidthLabel" GridPane.columnIndex="1" GridPane.rowIndex="1" />
<Label fx:id="bluePaneWidthLabel" GridPane.columnIndex="1" GridPane.rowIndex="2" />
<Label fx:id="redPaneWidthLabel" GridPane.columnIndex="1" GridPane.rowIndex="3" />
</children>
<padding>
<Insets bottom="3.0" left="3.0" right="3.0" top="3.0" />
</padding>
</GridPane>
</children>
</GridPane>
Application Class:
package sample;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;
import java.io.IOException;
public class Main extends Application {
#Override
public void start(Stage primaryStage) {
FXMLLoader loader = new FXMLLoader(getClass().getResource("width.fxml"));
Parent root = null;
try {
root = loader.load();
} catch (IOException ex) {
ex.printStackTrace();
}
if (root == null) return;
WidthController controller = loader.getController();
primaryStage.setScene(new Scene(root));
primaryStage.show();
controller.setStage(primaryStage);
}
public static void main(String[] args) {
launch(args);
}
}

Related

Javafx How to display image captured from web cam in imageview in another scene

I have this fxml layout. When I click on take photo it opens a screen for me to take a picture using web cam
Dialog layout to take pic from web cam
I want the picture captured on the web cam to replace the dummy image on the fxml layout beside take photo button.Here are my files:
FXML layout containing dummy image and take photo button
<HBox prefHeight="79.0" prefWidth="232.0" spacing="30.0">
<children>
<VBox prefHeight="100.0" prefWidth="100.0">
<children>
<ImageView fx:id="profilePic" fitHeight="99.0" fitWidth="118.0" nodeOrientation="INHERIT" pickOnBounds="true">
<image>
<Image url="#../images/profile_photo.png" />
</image>
</ImageView>
</children>
</VBox>
<VBox prefHeight="200.0" prefWidth="100.0">
<children>
<Button mnemonicParsing="false" onAction="#takePhoto" text="Take Photo">
<font>
<Font size="13.0" />
</font>
<VBox.margin>
<Insets bottom="20.0" top="10.0" />
</VBox.margin>
</Button>
<Button mnemonicParsing="false" onAction="#pickPhoto" prefHeight="31.0" prefWidth="85.0" text="Upload
">
<font>
<Font size="13.0" />
</font>
<VBox.margin>
<Insets bottom="10.0" />
</VBox.margin></Button>
</children>
</VBox>
</children>
</HBox>
Controller for the FXML Layout
public class AddParentController implements Initializable {
#Override
public void initialize(URL location, ResourceBundle resources) {
}
public void doAll(){
ImageSelection.getImageSelectionInstance().imageProperty()
.addListener((obs, oldImage, newImage) -> profilePic.setImage(newImage));
}
public void takePhoto(){
try {
Stage dialogStage = new Stage(StageStyle.UNDECORATED);
BorderPane root = FXMLLoader.load(getClass().getResource("../views/WebCamPreview.fxml"));
Scene scene = new Scene(root, 850, 390);
dialogStage.setUserData("fromAddParent");
dialogStage.initModality(Modality.APPLICATION_MODAL);
dialogStage.setScene(scene);
dialogStage.show();
} catch (IOException e) {
e.printStackTrace();
}
}
}
Dialog Layout containing WebCam Preview
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.geometry.Insets?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.image.ImageView?>
<?import javafx.scene.layout.BorderPane?>
<?import javafx.scene.layout.ColumnConstraints?>
<?import javafx.scene.layout.FlowPane?>
<?import javafx.scene.layout.GridPane?>
<?import javafx.scene.layout.RowConstraints?>
<?import javafx.scene.text.Font?>
<BorderPane prefHeight="390.0" prefWidth="850.0" xmlns="http://javafx.com/javafx/8.0.171" xmlns:fx="http://javafx.com/fxml/1" fx:controller="sample.controllers.WebCamPreviewController">
<!-- TODO Add Nodes -->
<bottom>
<FlowPane fx:id="fpBottomPane" alignment="CENTER" columnHalignment="CENTER" hgap="50.0" prefHeight="80.0" prefWidth="200.0" style="-fx-background-color:#ccc;">
<children>
<Button fx:id="btnStartCamera" focusTraversable="false" minHeight="-Infinity" minWidth="-Infinity" mnemonicParsing="false" onAction="#stopCamera" prefHeight="40.0" prefWidth="120.0" text="Capture">
<font>
<Font name="Segoe UI" size="18.0" fx:id="x1" />
</font>
</Button>
<Button fx:id="btnProceedCamera" focusTraversable="false" font="$x1" minHeight="-Infinity" minWidth="-Infinity" mnemonicParsing="false" onAction="#proceed" prefHeight="40.0" prefWidth="120.0" text="Proceed" />
<Button fx:id="btnResetCamera" focusTraversable="false" font="$x1" minHeight="-Infinity" minWidth="-Infinity" mnemonicParsing="false" onAction="#startCamera" prefHeight="40.0" prefWidth="120.0" text="Reset" />
<Button fx:id="btnDisposeCamera" focusTraversable="false" minHeight="-Infinity" minWidth="-Infinity" mnemonicParsing="false" onAction="#disposeCamera" prefHeight="40.0" prefWidth="120.0" text="Close">
<font>
<Font name="Segoe UI" size="18.0" fx:id="x11" />
</font>
</Button>
</children>
</FlowPane>
</bottom>
<center>
<BorderPane fx:id="bpWebCamPaneHolder" prefHeight="200.0" prefWidth="200.0">
<center>
<ImageView fx:id="imgWebCamCapturedImage" fitHeight="150.0" fitWidth="200.0" pickOnBounds="true" preserveRatio="true" BorderPane.alignment="CENTER" />
</center></BorderPane>
</center>
<top>
<GridPane minHeight="-Infinity" minWidth="-Infinity" prefHeight="80.0" style="-fx-background-color:#ccc;
">
<children>
<Label text="Webcam Image Capture" GridPane.columnIndex="0" GridPane.columnSpan="2" GridPane.halignment="CENTER" GridPane.hgrow="ALWAYS" GridPane.rowIndex="0" GridPane.rowSpan="1" GridPane.valignment="CENTER" GridPane.vgrow="ALWAYS">
<font>
<Font name="Segoe UI" size="34.0" />
</font>
<GridPane.margin>
<Insets top="10.0" />
</GridPane.margin>
</Label>
</children>
<columnConstraints>
<ColumnConstraints hgrow="SOMETIMES" maxWidth="795.0" minWidth="10.0" prefWidth="418.0" />
<ColumnConstraints hgrow="SOMETIMES" maxWidth="502.0" minWidth="10.0" prefWidth="482.0" />
</columnConstraints>
<rowConstraints>
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
</rowConstraints>
</GridPane>
</top>
</BorderPane>
WebCam Preview Controller
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStream;
import java.net.URL;
import java.util.ResourceBundle;
import com.github.sarxos.webcam.WebcamPanel;
import javafx.application.Platform;
import javafx.beans.property.ObjectProperty;
import javafx.beans.property.SimpleObjectProperty;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.concurrent.Task;
import javafx.embed.swing.SwingFXUtils;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.Button;
import javafx.scene.control.ComboBox;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.FlowPane;
import com.github.sarxos.webcam.Webcam;
import javafx.stage.Stage;
public class WebCamPreviewController implements Initializable {
#FXML Button btnStartCamera;
#FXML Button btnProceedCamera;
#FXML Button btnDisposeCamera,btnResetCamera;
#FXML BorderPane bpWebCamPaneHolder;
#FXML FlowPane fpBottomPane;
#FXML ImageView imgWebCamCapturedImage;
private BufferedImage grabbedImage;
private WebcamPanel selWebCamPanel = null;
private Webcam selWebCam = null;
private boolean stopCamera = false;
private ObjectProperty<Image> imageProperty = new SimpleObjectProperty<Image>();
Image mainiamge;
private String userData;
#Override
public void initialize(URL arg0, ResourceBundle arg1) {
fpBottomPane.setDisable(true);
try{
initializeWebCam(0);
}catch(Exception e){
e.printStackTrace();
}
Platform.runLater(() -> {
userData = (String) fpBottomPane.getScene().getWindow().getUserData();
setImageViewSize();
});
}
protected void setImageViewSize() {
double height = bpWebCamPaneHolder.getHeight();
double width = bpWebCamPaneHolder.getWidth();
imgWebCamCapturedImage.setFitHeight(height);
imgWebCamCapturedImage.setFitWidth(width);
imgWebCamCapturedImage.prefHeight(height);
imgWebCamCapturedImage.prefWidth(width);
imgWebCamCapturedImage.setPreserveRatio(true);
}
protected void initializeWebCam(final int webCamIndex) {
Task<Void> webCamIntilizer = new Task<Void>() {
#Override
protected Void call() throws Exception {
if(selWebCam == null)
{
selWebCam = Webcam.getWebcams().get(webCamIndex);
selWebCam.open();
}else
{
closeCamera();
selWebCam = Webcam.getWebcams().get(webCamIndex);
selWebCam.open();
}
startWebCamStream();
return null;
}
};
new Thread(webCamIntilizer).start();
fpBottomPane.setDisable(false);
btnProceedCamera.setDisable(true);
btnResetCamera.setDisable(true);
}
protected void startWebCamStream() {
stopCamera = false;
Task<Void> task = new Task<Void>() {
#Override
protected Void call() throws Exception {
while (!stopCamera) {
try {
if ((grabbedImage = selWebCam.getImage()) != null) {
Platform.runLater(new Runnable() {
#Override
public void run() {
mainiamge = SwingFXUtils
.toFXImage(grabbedImage, null);
imageProperty.set(mainiamge);
}
});
grabbedImage.flush();
}
} catch (Exception e) {
} finally {
}
}
return null;
}
};
Thread th = new Thread(task);
th.setDaemon(true);
th.start();
imgWebCamCapturedImage.imageProperty().bind(imageProperty);
}
private void closeStage() {
((Stage) fpBottomPane.getScene().getWindow()).close();
}
private void closeCamera()
{
if(selWebCam != null)
{
selWebCam.close();
}
}
public void proceed(){
ImageSelection.getImageSelectionInstance().setImage(imgWebCamCapturedImage.getImage());
AddParentController apc = new AddParentController();
apc.doAll();
closeStage();
}
public void proceedToAddPartner(){
}
public void stopCamera(ActionEvent event)
{
stopCamera = true;
btnStartCamera.setDisable(true);
btnResetCamera.setDisable(false);
btnProceedCamera.setDisable(false);
}
public void startCamera(ActionEvent event)
{
stopCamera = false;
startWebCamStream();
btnStartCamera.setDisable(false);
btnResetCamera.setDisable(true);
btnProceedCamera.setDisable(true);
}
public void disposeCamera(ActionEvent event)
{
//stopCamera = true;
//closeCamera();
//Webcam.shutdown();
//btnStopCamera.setDisable(true);
//btnStartCamera.setDisable(true);
closeStage();
}
}
Image Model
import javafx.beans.property.ObjectProperty;
import javafx.beans.property.SimpleObjectProperty;
import javafx.scene.image.Image;
public class ImageSelection {
private final ObjectProperty<Image> image = new SimpleObjectProperty<>();
private static ImageSelection imageSelectionInstance= new ImageSelection();
private ImageSelection(){}
public static ImageSelection getImageSelectionInstance() {
return imageSelectionInstance;
}
public ObjectProperty<Image> imageProperty() {
return image ;
}
public final void setImage(Image image) {
imageProperty().set(image);
}
public final Image getImage()
{
return imageProperty().get();
}
}
The challenge is to make the Image captured by the web cam to display in profilPic ImageView on the AddParent FXML Layout.

How do I get a grid to be static in a VBOX using Scene Builder?

I've just recently dipped into UI based applications and I'm having trouble getting the generated GridPane to not expand with the window. Ideally, I'd like to be able to hit the small button, have it generate a static grid, and then resize the root stage/scene to compensate for different dungeon sizes. The code below only implements the small button and then draws the grid under it.
This is a screenshot after I hit the small button.(and after I manually resized the window)
Controller Class
package Window;
import Data.Area;
import Model.Grid;
import Model.TileSet;
import javafx.event.ActionEvent;
import javafx.scene.Scene;
import javafx.scene.layout.GridPane;
import javafx.scene.paint.Color;
import javafx.scene.shape.Rectangle;
import javafx.stage.Modality;
import javafx.stage.Stage;
import java.io.IOException;
public class Controller {
public GridPane gridmane;
public void genSmall(ActionEvent actionEvent) throws IOException {
Grid grid = new Grid(new Area(40, 40));
grid.getPathfinder().shufflePartitions();
grid.getPathfinder().fillPartitions();
grid.getPathfinder().generateHallways();
importGrid(gridmane, grid);
Stage stage = new Stage();
stage.initModality(Modality.APPLICATION_MODAL);
stage.setOpacity(1);
stage.setTitle("My New Stage Title");
stage.setScene(new Scene(gridmane, 340, 400));
stage.show();
}
private void importGrid(GridPane gridPane, Grid grid) {
for (int i = 0; i < grid.getSize().height; i++) {
for (int j = 0; j < grid.getSize().width; j++) {
if (grid.getContent()[j + (i * grid.getSize().width)] == TileSet.floorTile) {
changeSquare(gridPane, i, j, Color.WHITE);
} else {
changeSquare(gridPane, i, j, Color.GRAY);
}
}
}
}
private void changeSquare(GridPane gridPane, int xCoordinate, int yCoordinate, Color color) {
Rectangle rect = new Rectangle();
rect.setStroke(Color.BLACK);
rect.setFill(color);
rect.setWidth(10);
rect.setHeight(10);
gridPane.add(rect, xCoordinate, yCoordinate);
}
}
Main Class
package Window;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;
import java.io.IOException;
public class Main extends Application {
Stage stage = new Stage();
int val = 40;
#Override
public void start(Stage primaryStage) throws Exception {
this.stage = primaryStage;
setVal(val);
}
public static void main(String[] args) {
launch(args);
}
public void setVal(int i) throws IOException {
Parent root = FXMLLoader.load(getClass().getResource("/view.fxml"));
stage.setTitle("Dungeon Generator");
stage.setScene(new Scene(root, 450, 450));
//primaryStage.setResizable(false);
stage.sizeToScene();
stage.show();
}
}
FXML File
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.geometry.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>
<VBox maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" prefHeight="258.0" prefWidth="332.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="Window.Controller">
<children>
<MenuBar>
<menus>
<Menu mnemonicParsing="false" text="File">
<items>
<MenuItem mnemonicParsing="false" text="Close" />
</items>
</Menu>
<Menu mnemonicParsing="false" text="Edit">
<items>
<MenuItem mnemonicParsing="false" text="Delete" />
</items>
</Menu>
<Menu mnemonicParsing="false" text="Help">
<items>
<MenuItem mnemonicParsing="false" text="About" />
</items>
</Menu>
</menus>
</MenuBar>
<HBox alignment="CENTER" prefHeight="100.0" prefWidth="200.0">
<children>
<Button alignment="CENTER" mnemonicParsing="false" onAction="#genSmall" prefHeight="27.0" prefWidth="64.0" text="Small" HBox.hgrow="ALWAYS">
<HBox.margin>
<Insets left="20.0" />
</HBox.margin>
</Button>
<Button alignment="CENTER" mnemonicParsing="false" text="Medium" HBox.hgrow="ALWAYS">
<HBox.margin>
<Insets left="20.0" />
</HBox.margin>
</Button>
<Button alignment="CENTER" mnemonicParsing="false" prefHeight="27.0" prefWidth="66.0" text="Large" HBox.hgrow="ALWAYS">
<HBox.margin>
<Insets left="20.0" />
</HBox.margin>
</Button>
</children>
</HBox>
<GridPane fx:id="gridmane" VBox.vgrow="NEVER">
<columnConstraints>
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
</columnConstraints>
<rowConstraints>
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
</rowConstraints>
</GridPane>
</children>
</VBox>
You need to get rid of those constraints of your GridPane rows/columns. For centering you could wrap the grid in a StackPane and prevent it's size from growing by using Region.USE_PREF_SIZE (=-Infinity) as max size constraints.
<StackPane VBox.vgrow="ALWAYS" >
<children>
<GridPane fx:id="gridmane" VBox.vgrow="NEVER" maxWidth="-Infinity" maxHeight="-Infinity" />
</children>
</StackPane>
public void genSmall(ActionEvent actionEvent) throws IOException {
Grid grid = new Grid(new Area(40, 40));
grid.getPathfinder().shufflePartitions();
grid.getPathfinder().fillPartitions();
grid.getPathfinder().generateHallways();
importGrid(gridmane, grid);
gridmane.getScene().getWindow().sizeToScene(); // resize window
}
private void importGrid(GridPane gridPane, Grid grid) {
gridPane.getChildren().clear(); // remove old children
for (int i = 0; i < grid.getSize().height; i++) {
for (int j = 0; j < grid.getSize().width; j++) {
if (grid.getContent()[j + (i * grid.getSize().width)] == TileSet.floorTile) {
changeSquare(gridPane, i, j, Color.WHITE);
} else {
changeSquare(gridPane, i, j, Color.GRAY);
}
}
}
}

JavaFX how I Can Get value form TableView to textfield

Someone help me, How I can pass a value from TableView(TableView show data from database) to textField and then the same value save to database??
Regards
ps I can Show the source code;
I think I m not able to explain it, I show u piece of code
this is my 1 st fxml file where I take data from user:
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.DatePicker?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.control.TextField?>
<?import javafx.scene.layout.ColumnConstraints?>
<?import javafx.scene.layout.GridPane?>
<?import javafx.scene.layout.HBox?>
<?import javafx.scene.layout.RowConstraints?>
<HBox maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/8.0.111" xmlns:fx="http://javafx.com/fxml/1" fx:controller="mojprogram.elkosz.controllers.AddCashRegisterController">
<children>
<GridPane prefHeight="398.0" prefWidth="624.0">
<columnConstraints>
<ColumnConstraints hgrow="SOMETIMES" maxWidth="295.0" minWidth="10.0" prefWidth="193.0" />
<ColumnConstraints hgrow="SOMETIMES" maxWidth="449.0" minWidth="10.0" prefWidth="407.0" />
</columnConstraints>
<rowConstraints>
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
</rowConstraints>
<children>
<Label text="Model Kasy Fiskalnej" GridPane.rowIndex="1" />
<Label text="Numer Seryjny" GridPane.rowIndex="2" />
<Label text="Data Zakupu" GridPane.rowIndex="3" />
<Label text="Data Pierwszego Przeglądu" GridPane.rowIndex="4" />
<Button fx:id="choisebutton" mnemonicParsing="false" onAction="#choiceCompany" text="Firma" />
<Label text="Data Następnego Przeglądu" GridPane.rowIndex="5" />
<TextField fx:id="companytextfieldCH" GridPane.columnIndex="1" />
<TextField fx:id="cashMachinetextfield" GridPane.columnIndex="1" GridPane.rowIndex="1" />
<TextField fx:id="serialnumber" GridPane.columnIndex="1" GridPane.rowIndex="2" />
<DatePicker fx:id="buydate" GridPane.columnIndex="1" GridPane.rowIndex="3" />
<DatePicker fx:id="firstcheck" GridPane.columnIndex="1" GridPane.rowIndex="4" />
<DatePicker fx:id="nextchech" GridPane.columnIndex="1" GridPane.rowIndex="5" />
<Button fx:id="addmachine" mnemonicParsing="false" onAction="#addCashRegister" text="Dodaj" GridPane.columnIndex="1" GridPane.rowIndex="6" />
</children>
</GridPane>
</children>
</HBox>
This is Controller:
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.DatePicker;
import javafx.scene.control.TextField;
import javafx.stage.Modality;
import javafx.stage.Stage;
import javafx.stage.StageStyle;
import java.io.IOException;
public class AddCashRegisterController {
#FXML
private Button addRegister;
#FXML
private TextField cashMachinetextfield;
#FXML
private TextField serialnumber;
#FXML
private DatePicker buydate;
#FXML
private DatePicker firstcheck;
#FXML
private DatePicker nextcheck;
#FXML
private TextField companytextfieldCH;
private CashRegisterModel cashRegisterModel;
public void choiceCompany() {
Stage stage = new Stage();
FXMLLoader loader = new FXMLLoader(getClass().getResource("/fxml/ChoiceCompany.fxml"));
try {
Parent parent = loader.load();
ChoiceCompanyController controller = loader.getController();
Scene scene = new Scene(parent);
stage.setScene(scene);
stage.initModality(Modality.APPLICATION_MODAL);
stage.initStyle(StageStyle.UNDECORATED);
stage.show();
} catch (IOException e) {
e.printStackTrace();
}
}
#FXML
private void initialize(){
this.cashRegisterModel = new CashRegisterModel();
}
public void addCashRegister() {
}
}
This is fxml file with Tableview
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.geometry.Insets?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.TableColumn?>
<?import javafx.scene.control.TableView?>
<?import javafx.scene.layout.HBox?>
<?import javafx.scene.layout.VBox?>
<VBox fx:id="choiceCompany" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="487.0" prefWidth="743.0" xmlns="http://javafx.com/javafx/8.0.111" xmlns:fx="http://javafx.com/fxml/1" fx:controller="mojprogram.elkosz.controllers.ChoiceCompanyController">
<children>
<TableView fx:id="CompanyTableView" onMouseClicked="#choice" prefHeight="446.0" prefWidth="743.0">
<columns>
<TableColumn fx:id="companycolumn" prefWidth="120.0" text="Nazwa Firmy" />
<TableColumn fx:id="NIPcolumn" prefWidth="116.0" text="NIP" />
<TableColumn fx:id="citycolumn" minWidth="0.0" prefWidth="115.0" text="Miejscowość" />
<TableColumn fx:id="streetcolum" minWidth="0.0" prefWidth="113.0" text="Ulica" />
<TableColumn fx:id="contactcolumn" prefWidth="124.0" text="Osoba Kontaktowa" />
<TableColumn fx:id="phonecolumn" prefWidth="153.0" text="Numer Telefonu" />
</columns>
</TableView>
<HBox alignment="CENTER_RIGHT" prefHeight="100.0" prefWidth="200.0">
<children>
<Button fx:id="closeButton" mnemonicParsing="false" onAction="#closeButtonaction" prefHeight="25.0" prefWidth="75.0" text="Ok" />
</children>
<opaqueInsets>
<Insets />
</opaqueInsets>
<VBox.margin>
<Insets right="35.0" />
</VBox.margin>
</HBox>
</children>
</VBox>
This is controller of this
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.scene.control.Button;
import javafx.scene.control.SelectionMode;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;
import mojprogram.elkosz.modelFX.CompanyFx;
import mojprogram.elkosz.modelFX.CompanyListModel;
import org.omg.CORBA.portable.ApplicationException;
import java.awt.*;
public class ChoiceCompanyController {
#FXML
public Button closeButton;
public VBox getChoiceCompany() {
return choiceCompany;
}
#FXML
private VBox choiceCompany;
#FXML
private TableView<CompanyFx> CompanyTableView;
#FXML
private TableColumn<CompanyFx, String> companycolumn;
#FXML
private TableColumn<CompanyFx, String> NIPcolumn;
#FXML
private TableColumn<CompanyFx, String> citycolumn;
#FXML
private TableColumn<CompanyFx, String> streetcolum;
#FXML
private TableColumn<CompanyFx, String> contactcolumn;
#FXML
private TableColumn<CompanyFx, String> phonecolumn;
private CompanyListModel companyListModel;
#FXML
private void initialize(){
this.companyListModel = new CompanyListModel();
try {
this.companyListModel.iniati();
} catch (ApplicationException e) {
e.printStackTrace();
}
this.CompanyTableView.setItems(this.companyListModel.getCompanyFxObservableList());
this.companycolumn.setCellValueFactory(cellData -> cellData.getValue().companyNameFxProperty());
this.NIPcolumn.setCellValueFactory(cellData -> cellData.getValue().NIPfxProperty());
this.citycolumn.setCellValueFactory(cellData -> cellData.getValue().cityfxProperty());
this.streetcolum.setCellValueFactory(cellData -> cellData.getValue().streetfxProperty());
this.contactcolumn.setCellValueFactory(cellData -> cellData.getValue().contactpersonfxProperty());
phonecolumn.setCellValueFactory(cellData -> cellData.getValue().phonenumberfxProperty());
}
#FXML
public void choice() {
//CompanyTableView.getSelectionModel().setSelectionMode(SelectionMode.SINGLE);
CompanyFx selected = CompanyTableView.getSelectionModel().getSelectedItem();
System.out.print(selected.toString());
}
#FXML
public void closeButtonaction() {
Stage stage = (Stage) closeButton.getScene().getWindow();
stage.close();
}
}
From this tableview I try to pass value to textfield and then I want to save it in new table of database
I don't understant what you need exactly ,but i think that you desire to get value from row of TableView and pass value of cell to TextField, you can do this if you acces to rows and get values from cells one by one.
PersonView.setRowFactory(event -> {
TableRow<Person> row = new TableRow<>();
row.setOnMouseEntered(event -> {
try {
if (row.isSelected) {
if (row.getItem().getId() != null && row.getItem().getName() != null) {
String Id=row.getItem.getId();
String Name=row.getItem.getId();
IdTextField.setText(Id);
NameTextField.setText(Name);
}
});
return row;
});
I hope this code can help you

JavaFX blur underneath area from pane

Is there any way to add a blur effect only to a part of an image defined by the area of a Pane? If you blur the pane over the image only the pane get blurred, but is there a way to blur the picture part underneath?
Here's an example of what I mean: It's simply just an image overlayed with a pane which has backgrouud and opacity set. Now I want to blur the part the pane lays on.
Main.java:
package application;
import javafx.application.Application;
import javafx.stage.Stage;
import javafx.scene.Scene;
import javafx.scene.layout.GridPane;
import javafx.fxml.FXMLLoader;
public class Main extends Application {
#Override
public void start(Stage primaryStage) {
try {
GridPane root = (GridPane)FXMLLoader.load(getClass().getResource("Sample.fxml"));
Scene scene = new Scene(root,500,500);
primaryStage.setScene(scene);
primaryStage.show();
} catch(Exception e) {
e.printStackTrace();
}
}
public static void main(String[] args) {
launch(args);
}
}
Sample.fxml:
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.image.Image?>
<?import javafx.scene.image.ImageView?>
<?import javafx.scene.layout.ColumnConstraints?>
<?import javafx.scene.layout.GridPane?>
<?import javafx.scene.layout.Pane?>
<?import javafx.scene.layout.RowConstraints?>
<GridPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" xmlns:fx="http://javafx.com/fxml/1" xmlns="http://javafx.com/javafx/8.0.111">
<columnConstraints>
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
</columnConstraints>
<rowConstraints>
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
</rowConstraints>
<children>
<ImageView fitHeight="495.0" fitWidth="535.0" pickOnBounds="true" preserveRatio="true" GridPane.columnIndex="1" GridPane.halignment="CENTER" GridPane.rowIndex="1" GridPane.valignment="CENTER">
<image>
<Image url="#../../../../Downloads/ZGEX2eX.jpg" />
</image>
</ImageView>
<Pane prefHeight="200.0" prefWidth="200.0" style="-fx-background-color: #012E56; -fx-opacity: 0.666;" GridPane.columnIndex="1" GridPane.halignment="CENTER" GridPane.rowIndex="1" GridPane.valignment="CENTER" />
</children>
</GridPane>
You can use the Clip of an ImageView to apply an effect only to a specific area of your image:
public class BlurredImageTest extends Application {
private DoubleProperty effectHeight = new SimpleDoubleProperty(80);
#Override
public void start(Stage primaryStage) {
Image image = new Image("yourImage.jpg");
ImageView img = new ImageView(image);
Rectangle clip = new Rectangle();
clip.widthProperty().bind(image.widthProperty());
clip.heightProperty().bind(image.heightProperty().subtract(effectHeight));
img.setClip(clip);
ImageView imgEffect = new ImageView(image);
Rectangle clipEffect = new Rectangle();
clipEffect.widthProperty().bind(image.widthProperty());
clipEffect.heightProperty().bind(effectHeight);
clipEffect.translateYProperty().bind(image.heightProperty().subtract(effectHeight));
imgEffect.setClip(clipEffect);
imgEffect.setEffect(new GaussianBlur());
StackPane root = new StackPane(img, imgEffect);
primaryStage.setScene(new Scene(root));
primaryStage.show();
}
public final void setEffectHeight(double value) {
effectHeight.set(value);
}
public static void main(String[] args) {
launch(args);
}
}

trying to display objects on JAVAFX table and i am getting java.lang.NullPointerException

i am having issue with lines 112/113/114 the program will compile without them,
am trying to get the the data from (ObservableList database) and display it on the table, i try to keep the variables as date,double. changed them to SimpleDoubleProperty, SimpleObjectProperty.
this is the exception am getting
at com.sun.glass.ui.win.WinApplication.lambda$null$145(Unknown
Source) at
com.sun.glass.ui.win.WinApplication$$Lambda$36/2117255219.run(Unknown
Source) ... 1 more Caused by: java.lang.NullPointerException at
org.xcellcomm.Controller.initialize(Controller.java:103) ... 23 more
Exception running application org.xcellcomm.Start
package org.xcellcomm;
import java.net.URL;
import java.util.ArrayList;
import java.util.Date;
import java.util.ResourceBundle;
import javafx.beans.property.SimpleDoubleProperty;
import javafx.beans.property.SimpleObjectProperty;
import javafx.beans.property.SimpleStringProperty;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.RadioButton;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import javafx.scene.control.ToggleGroup;
import javafx.scene.control.Alert;
import javafx.scene.control.Alert.AlertType;
import javafx.scene.control.cell.PropertyValueFactory;
import javafx.scene.control.Button;
import javafx.scene.control.CheckBox;
import javafx.scene.control.TextField;
public class Controller implements Initializable {
private final ObservableList<Mrc> data =
FXCollections.observableArrayList();
Date date;
ArrayList<Mrc> dailyMRC;
final static int VALUEBUNDLE = 5;
final static int PHP = 6;
final static int BLOCKIT = 1;
final static int RHAPSODY = 10;
final static int WORLDCALLING = 5;
final static int LOOKOUT = 3;
#FXML
private CheckBox checkboxFeatureLookout;
#FXML
private RadioButton plan40Radio;
#FXML
private CheckBox checkboxBlockIt;
#FXML
private CheckBox checkboxFeatureValueBundle;
#FXML
private TextField textfeildTodayGoal;
#FXML
private Button buttonAddActivation;
#FXML
private CheckBox checkboxFeatureRhpsody;
#FXML
private CheckBox checkboxFeatureWorldCalling;
#FXML
private RadioButton plan50Radio;
#FXML
private CheckBox checkboxFeaturePhp;
#FXML
private RadioButton plan60Radio;
#FXML
private TextField textfeildTodayActivations;
#FXML
private TableView<Plana> dailyActivationTable;
#FXML
private TableColumn<Plana, Date> dailyActivationTimeColon;
#FXML
private TableColumn<Plana, Double> dailyActivationPlanColon;
private final ObservableList<Plana> database =
FXCollections.observableArrayList();
#Override
public void initialize(URL location, ResourceBundle resources) {
dailyActivationPlanColon = new TableColumn<Controller.Plana, Double>();
dailyActivationTimeColon = new TableColumn<Controller.Plana, Date>();
dailyActivationTable.getColumns().addAll(dailyActivationPlanColon,dailyActivationTimeColon);
dailyMRC = new ArrayList<>();
ToggleGroup group = new ToggleGroup();
plan40Radio.setToggleGroup(group);
plan50Radio.setToggleGroup(group);
plan60Radio.setToggleGroup(group);
dailyActivationPlanColon.setCellValueFactory(new PropertyValueFactory<Plana, Double>("PlanProperty"));
dailyActivationTimeColon.setCellValueFactory(new PropertyValueFactory<Plana,Date>("dateProperty"));
dailyActivationTable.setItems(database);
}
//Getting input from the GUI and Calculate the MRC Constructor
private int newActivationCalculater(){
int mrc=0;
if(plan40Radio.isSelected())mrc=+40;
if(plan50Radio.isSelected())mrc=+50;
if(plan60Radio.isSelected())mrc=+60;
if(checkboxBlockIt.isSelected())mrc=+BLOCKIT;
if(checkboxFeatureLookout.isSelected())mrc=+LOOKOUT;
if(checkboxFeaturePhp.isSelected())mrc=+PHP;
if(checkboxFeatureRhpsody.isSelected())mrc=+RHAPSODY;
if(checkboxFeatureValueBundle.isSelected())mrc=+VALUEBUNDLE;
if(checkboxFeatureWorldCalling.isSelected())mrc=+WORLDCALLING;
return mrc;
}
//Getting the Current time for the mrc constructor
private Date currentTime(){
Date date = new Date();
return date;
}
public void buttonAddActivationPressed(){
if(plan40Radio.isSelected()||plan50Radio.isSelected()||plan60Radio.isSelected()){
double mrc = (double)newActivationCalculater();
Date date = currentTime();
//Mrc newactivation = ;
unselectAllItem();
database.add(new Plana((int)mrc, date));
todayactivationRefresh();
}//if end
else{//if user did not select plan
Alert alert = new Alert(AlertType.WARNING);
alert.setTitle("Warning!");
alert.setHeaderText("Something wrong:)");
alert.setContentText("You didn't select a Plan");
alert.showAndWait();}
}
void todayactivationRefresh(){
String todayactivation=dailyMRC.size()+"";
textfeildTodayActivations.setText(todayactivation);
}
void unselectAllItem(){
plan40Radio.setSelected(false);
plan50Radio.setSelected(false);
plan60Radio.setSelected(false);
checkboxBlockIt.setSelected(false);
checkboxFeatureLookout.setSelected(false);
checkboxFeaturePhp.setSelected(false);
checkboxFeatureValueBundle.setSelected(false);
checkboxFeatureWorldCalling.setSelected(false);
checkboxFeatureRhpsody.setSelected(false);
}
public class Plana {// its might not work because it is it's not public
// private final SimpleStringProperty dateStringProperty;
private final SimpleDoubleProperty PlanProperty;
private final SimpleObjectProperty<Date> dateProperty;
private Plana( double gPlan, Date gDate) {
// this.dateStringProperty = new SimpleStringProperty(gStringDate);
this.PlanProperty = new SimpleDoubleProperty(gPlan);
this.dateProperty = new SimpleObjectProperty<Date>(gDate);
}
/**
* #return the dateStringProperty
*/
// public SimpleStringProperty getDateStringProperty() {
// return dateStringProperty;
//}
/**
* #return the planProperty
*/
public SimpleDoubleProperty getPlanProperty() {
return PlanProperty;
}
/**
* #return the dateProperty
*/
public SimpleObjectProperty<Date> getDateProperty() {
return dateProperty;
}
}
}
and here is the startclass:
package org.xcellcomm;
import java.util.Date;
import javafx.application.Application;
import javafx.beans.property.SimpleDoubleProperty;
import javafx.beans.property.SimpleObjectProperty;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import javafx.scene.control.cell.PropertyValueFactory;
import javafx.stage.Stage;
public class Start extends Application {
#Override
public void start(Stage stage) throws Exception {
Parent root = FXMLLoader.load(getClass().getResource("mainMrc.fxml"));
Scene scene = new Scene(root);
stage.setTitle("MRC Monitor");
stage.setScene(scene);
stage.show();
}
public static void main(String []args){
launch(args);
}
}
mainMrc.fxml
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.*?>
<?import javafx.scene.text.*?>
<?import javafx.scene.chart.*?>
<?import javafx.geometry.*?>
<?import javafx.scene.control.*?>
<?import java.lang.*?>
<?import javafx.scene.layout.*?>
<?import javafx.scene.layout.VBox?>
<BorderPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="600.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="org.xcellcomm.Controller">
<center>
<VBox prefHeight="200.0" prefWidth="100.0" BorderPane.alignment="CENTER">
<children>
<Label text="Add New Activation :">
<VBox.margin>
<Insets />
</VBox.margin>
</Label>
<HBox prefHeight="100.0" prefWidth="200.0">
<children>
<HBox prefHeight="90.0" prefWidth="200.0">
<children>
<VBox prefHeight="200.0" prefWidth="100.0">
<children>
<Label text="Select Plan Rate :" />
<RadioButton fx:id="plan40Radio" mnemonicParsing="false" text="40 or less Plan" />
<RadioButton fx:id="plan50Radio" mnemonicParsing="false" text="50 Plan" />
<RadioButton fx:id="plan60Radio" mnemonicParsing="false" text="60 Plan" />
<Region prefHeight="16.0" prefWidth="100.0" />
<Button fx:id="buttonAddActivation" mnemonicParsing="false" onAction="#buttonAddActivationPressed" text="Add Activation" />
</children>
</VBox>
</children>
</HBox>
<VBox prefHeight="102.0" prefWidth="163.0">
<children>
<Label text="Added Features :" />
<CheckBox fx:id="checkboxFeaturePhp" layoutX="10.0" layoutY="27.0" mnemonicParsing="false" text="PHP" />
<CheckBox fx:id="checkboxBlockIt" mnemonicParsing="false" text="Block it" />
<CheckBox fx:id="checkboxFeatureValueBundle" mnemonicParsing="false" text="Value Bundle" />
</children>
</VBox>
<VBox prefHeight="200.0" prefWidth="100.0">
<children>
<Label text=" " />
<CheckBox fx:id="checkboxFeatureLookout" mnemonicParsing="false" text="Lookout MS" />
<CheckBox fx:id="checkboxFeatureRhpsody" mnemonicParsing="false" text="Rhapsody" />
<CheckBox fx:id="checkboxFeatureWorldCalling" mnemonicParsing="false" text="World Calling" />
</children>
</VBox>
</children>
</HBox>
<Region prefHeight="23.0" prefWidth="600.0" />
<HBox prefHeight="131.0" prefWidth="580.0">
<children>
<TableView prefHeight="100.0" prefWidth="263.0">
<columns>
<TableColumn prefWidth="109.0" text="Time" />
<TableColumn prefWidth="82.0" text="Plan" />
</columns>
<HBox.margin>
<Insets left="10.0" />
</HBox.margin>
</TableView>
<Region prefHeight="200.0" prefWidth="200.0" HBox.hgrow="ALWAYS" />
<TableView prefHeight="100.0" prefWidth="309.0">
<columns>
<TableColumn prefWidth="147.0" text="Date" />
<TableColumn prefWidth="90.0" text="MRC" />
</columns>
<HBox.margin>
<Insets right="10.0" />
</HBox.margin>
</TableView>
</children>
</HBox>
<Region prefHeight="29.0" prefWidth="580.0" />
<HBox prefHeight="100.0" prefWidth="200.0">
<children>
<VBox prefHeight="150.0" prefWidth="218.0">
<children>
<Label text="Today Activations" />
<TextField fx:id="textfeildTodayActivations" editable="false" maxWidth="100.0" prefHeight="39.0" prefWidth="100.0" promptText="Activations">
<font>
<Font size="18.0" />
</font>
</TextField>
<Label text="Today Goal" />
<TextField fx:id="textfeildTodayGoal" editable="false" maxWidth="100.0" prefHeight="39.0" prefWidth="100.0" promptText="Goal">
<font>
<Font size="18.0" />
</font>
</TextField>
<Label text="Current Process" />
<ProgressBar prefWidth="200.0" progress="0.0" />
</children>
</VBox>
<Region prefHeight="150.0" prefWidth="80.0" HBox.hgrow="ALWAYS" />
<LineChart prefHeight="150.0" prefWidth="281.0">
<xAxis>
<CategoryAxis side="BOTTOM" />
</xAxis>
<yAxis>
<NumberAxis side="LEFT" />
</yAxis>
</LineChart>
</children>
</HBox>
</children>
<BorderPane.margin>
<Insets left="10.0" right="10.0" />
</BorderPane.margin>
</VBox>
</center>
<top>
<MenuBar BorderPane.alignment="CENTER">
<menus>
<Menu mnemonicParsing="false" text="File">
<items>
<MenuItem mnemonicParsing="false" text="Close" />
</items>
</Menu>
<Menu mnemonicParsing="false" text="Edit">
<items>
<MenuItem mnemonicParsing="false" text="Delete" />
</items>
</Menu>
<Menu mnemonicParsing="false" text="Help">
<items>
<MenuItem mnemonicParsing="false" text="About" />
</items>
</Menu>
</menus>
</MenuBar>
</top>
</BorderPane>
Your tableView in the FXML file doesn't have and id, you have <TableView prefHeight="100.0" prefWidth="263.0">and it should have assign an id as you have in yours checkboxs,radiobuttons,etc.

Resources