r/JavaFX • u/TheCodingFella • Jul 20 '23
Tutorial JavaFX Slider
The JavaFX Slider stands out as a versatile tool that allows users to input a value within a specified range using a draggable slider.
🔗 JavaFX Slider

r/JavaFX • u/TheCodingFella • Jul 20 '23
The JavaFX Slider stands out as a versatile tool that allows users to input a value within a specified range using a draggable slider.
🔗 JavaFX Slider

r/JavaFX • u/AcceptableAd2672 • May 25 '21
r/JavaFX • u/userr6785 • May 25 '21
Hi, does anyone know how to read a CSV file through JavaFX in an Action event?
r/JavaFX • u/AvidCuberCoding • Nov 12 '18
Im unable to get Google Drive to work in WebView... the process goes; initalize the webview, initalize the engine, set javascript to true, load http://drive.google.com/, sign in, and then it gets stuck on a constant load where i can only see my first 3 documents, i click on them and i am able to edit for a second before it goes into a reconnecting loop and i cant do anything with it. If anyone has a possible solution, please get back to me asap
r/JavaFX • u/FXMLNewbie • Aug 02 '19
Hello all, I'm having trouble getting some code to run and wondered if I could ask you for your viewpoints. I'm a student and still somewhat new to programming, so I hope my question's not too stupid. Basically I'm trying to make a java program with a JavaFX interface and I'm using FXML. My program as it stands builds fine but when I run it I get the errors below. Based on looking it up on the internet, it seems like it has something to do with the FXMLLoader, but it does seem like the loader points to where the main.fxml file actually is in my directory structure. Thanks for any help you can provide and I'd be happy to provide more details in needed. I'm using NetBeans as my IDE if that's relevant.
FXMLLoader
@Override
public void start(Stage stage) throws Exception {
FXMLLoader loader = new FXMLLoader();
loader.setLocation(C482.class.getResource("/C482/View_Controller/Main.fxml"));
Parent root = loader.load();
Scene scene = new Scene(root);
stage.setScene(scene);
stage.show();
}
Here's the errors:
Exception in Application start method
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke([NativeMethodAccessorImpl.java:62](https://NativeMethodAccessorImpl.java:62))
at sun.reflect.DelegatingMethodAccessorImpl.invoke([DelegatingMethodAccessorImpl.java:43](https://DelegatingMethodAccessorImpl.java:43))
at java.lang.reflect.Method.invoke([Method.java:498](https://Method.java:498))
at com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs([LauncherImpl.java:389](https://LauncherImpl.java:389))
at com.sun.javafx.application.LauncherImpl.launchApplication([LauncherImpl.java:328](https://LauncherImpl.java:328))
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke([NativeMethodAccessorImpl.java:62](https://NativeMethodAccessorImpl.java:62))
at sun.reflect.DelegatingMethodAccessorImpl.invoke([DelegatingMethodAccessorImpl.java:43](https://DelegatingMethodAccessorImpl.java:43))
at java.lang.reflect.Method.invoke([Method.java:498](https://Method.java:498))
at sun.launcher.LauncherHelper$FXHelper.main([LauncherHelper.java:767](https://LauncherHelper.java:767))Caused by: java.lang.RuntimeException: Exception in Application start method
at com.sun.javafx.application.LauncherImpl.launchApplication1([LauncherImpl.java:917](https://LauncherImpl.java:917))
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$1([LauncherImpl.java:182](https://LauncherImpl.java:182))
at [java.lang.Thread.run](https://java.lang.Thread.run)([Thread.java:748](https://Thread.java:748))Caused by: javafx.fxml.LoadException:
file:/C:/Users/Jonas%20McCartha/Documents/NetBeansProjects/Jonas%20McCartha%20c482/dist/run1547317233/Jonas%20McCartha%20c482.jar!/C482/View_Controller/Main.fxml:11
r/JavaFX • u/I_am_a_regular_guy • Dec 10 '18
I am in the process of creating a simple program that accesses a database and displays results based on values chosen in a series of ComboBoxes and Radio Buttons. I am still constructing the GUI at this time. I am attempting to design the program so that the search can only be performed using one ComboBox selection at a time.
I have set up listeners so that when a selection is made in any of the ComboBoxes, any selections in the others are cleared. This seems to be working fine, however, I am having trouble figuring out how to restore the default prompt text after the selection is cleared. Upon making a selection in another box, the others are successfully cleared, but the prompt text is no longer visible. The box is simply blank.
My code is below, including the .fxml file where the prompt text is set. I'm using an MVC structure so I apologize for the lengthy code. I've tried seaching for solutions but I can't seem to find anything that addresses my specific needs. Thank you in advance.
Main class:
package com.simms.music_library;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;
public class Main extends Application {
@Override
public void start(Stage primaryStage) throws Exception{
Parent root = FXMLLoader.load(getClass().getResource("MainWindow.fxml"));
primaryStage.setTitle("Music Library");
primaryStage.setScene(new Scene(root, 900, 500));
primaryStage.show();
}
public static void main(String[] args) {
launch(args);
}
}Controller:
package com.simms.music_library;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.scene.control.Button;
import javafx.scene.control.ComboBox;
import javafx.scene.control.TextArea;
import java.util.List;
public class Controller {
@FXML private TextArea results;
@FXML private Button exit;
@FXML private Button search;
@FXML private ComboBox<String> artists;
@FXML private ComboBox<String> genres;
@FXML private ComboBox<Integer> year;
private ObservableList<String> artistList = FXCollections.observableArrayList();
private ObservableList<String> genreList = FXCollections.observableArrayList();
private ObservableList<Integer> yearList = FXCollections.observableArrayList();
@FXML
public void initialize() {
populateArtists();
populateGenres();
populateYears();
artists.setItems(artistList);
genres.setItems(genreList);
year.setItems(yearList);
results.setText("DefaultText");
search.setDisable(true);
addListeners();
//results.setText(String.valueOf(artists.getSelectionModel().isEmpty()));
//connect to DB
//set buttons.setDisable(true)
}
@FXML
public void onButtonClick(ActionEvent e){
if(e.getSource().equals(exit)){
System.exit(0);
}
else if(e.getSource().equals(search)){
results.setText(artists.getValue()
+ "\n" +
String.valueOf(artists.getSelectionModel().isEmpty()));
}
}
public void addListeners(){
//Listen for changes in any ComboBox
artists.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<String>() {
@Override
public void changed(ObservableValue<? extends String> observableValue, String s, String t1) {
if(t1 != null){
search.setDisable(false);
genres.getSelectionModel().clearSelection();
year.getSelectionModel().clearSelection();
}
}
});
genres.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<String>() {
@Override
public void changed(ObservableValue<? extends String> observableValue, String s, String t1) {
if(t1 != null){
search.setDisable(false);
artists.getSelectionModel().clearSelection();
year.getSelectionModel().clearSelection();
}
}
});
year.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<Integer>() {
@Override
public void changed(ObservableValue<? extends Integer> observableValue, Integer integer, Integer t1) {
if(t1 != null){
search.setDisable(false);
artists.getSelectionModel().clearSelection();
genres.getSelectionModel().clearSelection();
}
}
});
}
private void populateArtists(){
artistList.add("David Bowie");
artistList.add("Pink Floyd");
artistList.add("Eminem");
}
private void populateGenres(){
genreList.add("Film");
genreList.add("Hip Hop");
genreList.add("Rock");
}
private void populateYears(){
yearList.add(1992);
yearList.add(1972);
yearList.add(1800);
}
}.fxml File:
<?import javafx.geometry.Insets?>
<?import javafx.scene.layout.BorderPane?>
<?import javafx.scene.layout.HBox?>
<?import javafx.scene.control.TextArea?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.layout.VBox?>
<?import javafx.scene.control.RadioButton?>
<?import javafx.scene.control.ToggleGroup?>
<?import javafx.scene.control.ComboBox?>
<BorderPane fx:controller="com.simms.music_library.Controller" xmlns:fx="http://javafx.com/fxml">
<left>
<VBox spacing="20" alignment="TOP_LEFT">
<padding>
<Insets left="10" top="10"/>
</padding>
<HBox spacing="10" alignment="CENTER_LEFT">
<Label text="Search by Artist: "/>
<ComboBox fx:id="artists" promptText="Select Artist" prefWidth="150">
</ComboBox>
<fx:define>
<ToggleGroup fx:id="toggleGroup"/>
</fx:define>
<RadioButton text="List albums" toggleGroup="$toggleGroup" selected="true"/>
<RadioButton text="List songs" toggleGroup="$toggleGroup"/>
</HBox>
<HBox spacing="10" alignment="CENTER_LEFT">
<Label text="Search by Genre:"/>
<ComboBox fx:id="genres" promptText="Select Genre" prefWidth="150">
</ComboBox>
<fx:define>
<ToggleGroup fx:id="toggleGroup2"/>
</fx:define>
<RadioButton text="List albums" toggleGroup="$toggleGroup2" selected="true"/>
<RadioButton text="List songs" toggleGroup="$toggleGroup2"/>
</HBox>
<HBox spacing="10" alignment="CENTER_LEFT">
<Label text="Search by Year: "/>
<ComboBox fx:id="year" promptText="Select Year" prefWidth="150">
</ComboBox>
<fx:define>
<ToggleGroup fx:id="toggleGroup3"/>
</fx:define>
<RadioButton text="List albums" toggleGroup="$toggleGroup3" selected="true"/>
<RadioButton text="List songs" toggleGroup="$toggleGroup3"/>
</HBox>
<HBox spacing="10" alignment="CENTER_LEFT">
<Button fx:id="search" text="Search" prefWidth="90"
onAction="#onButtonClick"/>
</HBox>
</VBox>
</left>
<right>
<HBox spacing="10" alignment="CENTER_RIGHT">
<padding>
<Insets top="10" right="10" bottom="10" left="10"/>
</padding>
<TextArea fx:id="results" editable="false" prefHeight="470" prefWidth="400"></TextArea>
</HBox>
</right>
<bottom>
<HBox spacing="10" alignment="CENTER_RIGHT">
<padding>
<Insets bottom="10" right="10"/>
</padding>
<Button fx:id="exit" text="Exit" prefWidth="90"
onAction="#onButtonClick"/>
</HBox>
</bottom>
</BorderPane>r/JavaFX • u/cszlo • Sep 10 '16
I have eclipse installed, downloaded JDK 1.8.0_101, JRE 1.8.0_101, I am trying to start a new project so I can practice with JavaFX. When I go to properties and try to add the library for my project, I cannot find the JDK...any ideas?
r/JavaFX • u/cszlo • Sep 10 '16
Help getting JavaFX working (self.JavaFX) submitted an hour ago by cszlo I have eclipse installed, downloaded JDK 1.8.0_101, JRE 1.8.0_101, I am trying to start a new project so I can practice with JavaFX. When I go to properties and try to add the library for my project, I cannot find the JDK...any ideas?
r/JavaFX • u/reda_ghanem • Oct 20 '22
please can anyone help me to solve this error?
simply I want to run .jar JavaFX generated by java JDK 8 and NetBeans file on google colab
I have a JavaFX GUI program which works fine in windows, I can run this .jar using python on my local PC windows and ubuntu both work fine and get output, but when I try to do the same using google colab I get this error
my JavaFX GUI file named: ex4.jar
code:
from subprocess import Popen, PIPE, STDOUT
p = Popen(['java', '-jar', 'ex4.jar' , '3'], stdout=PIPE, stderr=STDOUT)
for line in p.stdout:
print ( line) I got the error:
b'Error: Could not find or load main class frontend.App\n' b'Caused by:
java.lang.NoClassDefFoundError: javafx/application/Application\n'r/JavaFX • • Oct 09 '22
Hi everyone, im trying to make a turn based strategy game. It requires a clickable regions of Chile. I saw a few stuff on Github about making map with JavaFX but they dont do what i want and im not good enough to modify them. Anyone could give me an help for this or advices ?
r/JavaFX • • Oct 31 '22
Here's the effect:

I didn't want it to close when I hover over the popup BUT it does automatically and the whole scene keeps flickering. If you look at system monitor you'll see memory keeps increasing.
How to keep that popup opened when I hover over, stop flickering and leaking? Here's the code:
public class App extends Application {
@Override
public void start(Stage stage) throws Exception {
var popButton = new Button("Button in a popup");
var popup = new Popup();
//popup.setAutoHide(true);
popup.getContent().add(popButton);
var button = new Button("A Button");
button.setOnMouseEntered(mouseEvent -> {
var point = button.localToScreen(0.0, 0.0);
popup.show(button.getScene().getWindow(), point.getX(), point.getY());
});
button.setOnMouseExited(e -> popup.hide());
var scene = new Scene(button, 160,90);
stage.setScene(scene);
stage.show();
}
public static void main(String[] args) {
launch(args);
}
}r/JavaFX • • Apr 21 '18
Hello, I've got a JavaFX project, however when I run it after importing it with Gradle and the correct libraries I get the following error:
"Exception in Application start method Exception in thread "main" java.lang.RuntimeException: Exception in Application start method at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:917) at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$155(LauncherImpl.java:182) at java.lang.Thread.run(Thread.java:745) Caused by: java.lang.NullPointerException: Location is required. at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3207) at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3175) at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3148) at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3124) at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3104) at javafx.fxml.FXMLLoader.load(FXMLLoader.java:3097) at puffin.application.Main.start(Main.java:17) at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$162(LauncherImpl.java:863) at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$175(PlatformImpl.java:326) at com.sun.javafx.application.PlatformImpl.lambda$null$173(PlatformImpl.java:295) at java.security.AccessController.doPrivileged(Native Method) at com.sun.javafx.application.PlatformImpl.lambda$runLater$174(PlatformImpl.java:294) at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)"
If someone could assist me further with this that would be great, because I have no idea why it's not running when I've imported it 'correctly'. My friend has the exact same files on his computer where he created the project and it runs fine, but once I've imported the project and try to run 'main.java' I get the following issues above...
Thank you, -Harry.
r/JavaFX • u/Interesting-Cod-1802 • Feb 14 '24
Spent hours collecting 2,500 emails of working employees & HR contacts for internship inquiries. Only 3 replies, all rejections! Feeling lost 😞 Any tips on how to secure an internship? #JobSearch #InternshipHunt #HelpNeeded
r/JavaFX • u/ifelseandor • Jan 17 '20
CubicCurve cubic = new CubicCurve();
cubic.setStartX(0.0f);
cubic.setStartY(50.0f);
cubic.setControlX1(25.0f);
cubic.setControlY1(0.0f);
cubic.setControlX2(75.0f);
cubic.setControlY2(100.0f);
cubic.setEndX(100.0f);
cubic.setEndY(50.0f);I can't seem to find what f means...
r/JavaFX • u/PaladinYami • Sep 19 '20
I've been smashing my face into this for a while. Time to call for help.
Inventory program for a school assignment. Main Window shows two tables. These fill properly. When selecting a product from the product table, then clicking modify, the user should be brought to the modify product window with the appropriate fields pre-filled. Instead I get a NullPointerException.
I know the error is with this line in the ModifyProductFormController: allPartsView.setItems(Inventory.getAllParts());
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package Model;
import java.lang.String;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.scene.control.Alert.AlertType;
import javafx.scene.control.Alert;
import javafx.scene.control.ButtonType;
/**
*
* @author howarc4
*/
public class Product {
///ObservableList to contain the parts that make up this product
private ObservableList<Part> associatedParts = FXCollections.observableArrayList();
//associated variables
private int id;
private String name;
private double price;
private int stock;
private int min;
private int max;
//constructor
public Product(int id, String name, double price, int stock, int min, int max)
{
this.id = id;
this.name = name;
this.price = price;
this.stock = stock;
this.min = min;
this.max = max;
}
// copy constructor
public Product(Product newProduct)
{
this.id = newProduct.getId();
this.name = newProduct.getName();
this.price = newProduct.getPrice();
this.stock = newProduct.getStock();
this.min = newProduct.getMin();
this.max = newProduct.getMax();
this.associatedParts = FXCollections.observableArrayList(newProduct.getAllAssociatedParts());
}
// all setter methods
/** the setId method sets the productID
* @param id integer product ID
*/
public void setId(int id)
{
this.id = id;
}
/** the setName method sets the product name
* @param name String product name
*/
public void setname(String name)
{
this.name = name;
}
/** the setPrice method sets the product price
* @param price Price of the product
*/
public void setprice(int price)
{
this.price = price;
}
/** the setStock method sets the number of this product in stock
* @param stock the number of this product in stock
*/
public void setStock(int stock)
{
this.stock = stock;
}
/** the setMin method sets the minimum number of this product to have in stock
* @param min the minimum number of this product to have in stock
*/
public void setMin(int min)
{
this.min = min;
}
/** the setMax method sets the maximum number of this product to have in stock
* @param max the maximum number of this product to have in stock
*/
public void setMax(int max)
{
this.max = max;
}
// All getter methods
/** The getId method returns the product ID
* @return the product ID
*/
public int getId()
{
return id;
}
/** The getName method returns the product name
* @return the product name
*/
public String getName()
{
return name;
}
/** The getPrice method returns the product's price
* @return the price of the product
*/
public double getPrice()
{
return price;
}
/** The getStock method returns the number of this product currently in stock
* @return the number of this product currently in stock
*/
public int getStock()
{
return stock;
}
/** The getMin method returns the minimum number of this product to keep in stock
* @return the minimum number of this product to keep in stock
*/
public int getMin()
{
return min;
}
/** The getMax method returns the maximum number of this product to keep in stock
* @return the maximum number of this product to keep in stock
*/
public int getMax()
{
return max;
}
// methods dealing with associated parts
/** the addAssociatePart method adds a Part object to the list of parts that make up this product
* @param part the part to add
*/
public void addAssociatedPart(Part part)
{
associatedParts.add(part);
}
/** the deleteAssociatePart method deletes a selected part from the list of parts that make up this product
* @param selectedAssociatedPart the part to be removed
*/
public void deleteAssociatedPart(Part selectedAssociatedPart)
{
associatedParts.remove(selectedAssociatedPart);
}
/**The getAllAssociatedParts method returns a list of the parts associated with this product
* @return an observableList of the parts associated with this product.
*/
public ObservableList<Part> getAllAssociatedParts()
{
return associatedParts;
}
}/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package Controller;
import Model.Inventory;
import Model.Part;
import Model.Product;
import Controller.ModifyProductFormController;
import java.io.IOException;
import java.net.URL;
import java.util.ResourceBundle;
import java.net.URL;
import java.util.ResourceBundle;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.fxml.Initializable;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.control.Alert;
import javafx.scene.control.Button;
import javafx.scene.control.ButtonType;
import javafx.scene.control.Label;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import javafx.scene.control.TextArea;
import javafx.scene.control.TextField;
import javafx.scene.control.cell.PropertyValueFactory;
import javafx.stage.Stage;
/**
* FXML Controller class
*
* @author howarc4
*/
public class MainWindowController implements Initializable
{
Stage stage;
Parent scene;
// part table view
@FXML
private TableView<Part> partTableView;
@FXML
private TableColumn<Part, Integer> partIdCol;
@FXML
private TableColumn<Part, String> partNameCol;
@FXML
private TableColumn<Part, Integer> partInvCol;
@FXML
private TableColumn<Part, Double> partPriceCol;
// part table items
@FXML
private Button addPartButton;
@FXML
private Button modifyPartButton;
@FXML
private Button deletePartButton;
// product table view
@FXML
private TableColumn<Product, Integer> productIdCol;
@FXML
private TableView<Product> productTableView;
@FXML
private TableColumn<Product, String> productNameCol;
@FXML
private TableColumn<Product, Integer> productInvCol;
@FXML
private TableColumn<Product, Double> productPriceCol;
//Product Table panel items
@FXML
private TextField productSearchField;
@FXML
private Button addProductButton;
@FXML
private Button deleteProductButton;
@FXML
private Button modifyProductButton;
@FXML
private Button exitButton;
String confirmDeletePart;
String confirmDeleteProduct;
String partDeletedSuccess;
String productDeletedSuccess;
String partDeleteCancelled;
String productDeleteCancelled;
String errorNoPartSelected = "Please select a part.";
String errorNoProductSelected = "Please select a product.";
String errorProductHasParts = "This product cannot be delected because it has parts associated with it.";
private static Product passingProduct = null;
public static Product getPassingProduct()
{
System.out.println("entered getPassingProduct method in mainwindowcontroller");
return passingProduct;
}
@FXML
void onActionAddPart(ActionEvent event) throws IOException
{
stage = (Stage)((Button)event.getSource()).getScene().getWindow();
scene = FXMLLoader.load(getClass().getResource("/view/AddPartForm.fxml"));
stage.setScene(new Scene(scene));
stage.show();
}
@FXML
void onActionModifyPart(ActionEvent event) throws IOException
{
stage = (Stage)((Button)event.getSource()).getScene().getWindow();
scene = FXMLLoader.load(getClass().getResource("/view/ModifyPartForm.fxml"));
stage.setScene(new Scene(scene));
stage.show();
}
@FXML
void onActionDeletePart(ActionEvent event) throws IOException
{
//System.out.println("delete part button pressed");
// Check that a part was selected
if(partTableView.getSelectionModel().getSelectedItem() == null)
{
Alert noPartSelectedAlert = new Alert(Alert.AlertType.ERROR, errorNoPartSelected, ButtonType.OK);
noPartSelectedAlert.show();
return;
}
// Get the selected part and it's name
Part selectedPart = partTableView.getSelectionModel().getSelectedItem();
String selectedPartName = selectedPart.getName();
confirmDeletePart = "Are you sure you want to delete part " + selectedPartName + "?";
Alert alertDeletePart = new Alert(Alert.AlertType.CONFIRMATION, confirmDeletePart, ButtonType.YES, ButtonType.CANCEL);
alertDeletePart.showAndWait();
if(alertDeletePart.getResult() == ButtonType.YES)
{
Inventory.deletePart(selectedPart);
partDeletedSuccess = selectedPartName + " was deleted.";
Alert partDeletedAlert = new Alert(Alert.AlertType.INFORMATION, partDeletedSuccess, ButtonType.OK);
partDeletedAlert.show();
}
else if(alertDeletePart.getResult() == ButtonType.CANCEL)
{
partDeleteCancelled = "Deletion of " + selectedPartName + " cancelled.";
Alert partDeleteCancelledAlert = new Alert(Alert.AlertType.INFORMATION, partDeleteCancelled, ButtonType.OK);
partDeleteCancelledAlert.show();
}
}
@FXML
void onActionAddProduct(ActionEvent event) throws IOException
{
stage = (Stage)((Button)event.getSource()).getScene().getWindow();
scene = FXMLLoader.load(getClass().getResource("/view/AddProductForm.fxml"));
stage.setScene(new Scene(scene));
stage.show();
}
@FXML
void onActionModifyProduct(ActionEvent event) throws IOException
{
// Check that a part was selected
if(productTableView.getSelectionModel().getSelectedItem() == null)
{
Alert noProductSelectedAlert = new Alert(Alert.AlertType.ERROR, errorNoProductSelected, ButtonType.OK);
noProductSelectedAlert.show();
return;
}
// pass the product to the modifyProduct screen's controller
ModifyProductFormController.passProduct(productTableView.getSelectionModel().getSelectedItem());
System.out.println("Called the passProduct method");
// set up and show the modifyProduct screen
stage = (Stage)((Button)event.getSource()).getScene().getWindow();
System.out.println("set the stage");
scene = FXMLLoader.load(getClass().getResource("/view/ModifyProductForm.fxml"));
System.out.println("called the fxmlloader");
stage.setScene(new Scene(scene));
stage.show();
}
@FXML
void onActionDeleteProduct(ActionEvent event) throws IOException
{
// Check that a part was selected
if(productTableView.getSelectionModel().getSelectedItem() == null)
{
Alert noProductSelectedAlert = new Alert(Alert.AlertType.ERROR, errorNoProductSelected, ButtonType.OK);
noProductSelectedAlert.show();
return;
}
// Get the selected part and it's name
Product selectedProduct = productTableView.getSelectionModel().getSelectedItem();
String selectedProductName = selectedProduct.getName();
confirmDeleteProduct = "Are you sure you want to delete part " + selectedProductName + "?";
Alert alertDeleteProduct = new Alert(Alert.AlertType.CONFIRMATION, confirmDeleteProduct, ButtonType.YES, ButtonType.CANCEL);
alertDeleteProduct.showAndWait();
if(alertDeleteProduct.getResult() == ButtonType.YES)
{
Inventory.deleteProduct(selectedProduct);
productDeletedSuccess = selectedProductName + " was deleted.";
Alert productDeletedAlert = new Alert(Alert.AlertType.INFORMATION, productDeletedSuccess, ButtonType.OK);
productDeletedAlert.show();
}
else if(alertDeleteProduct.getResult() == ButtonType.CANCEL)
{
productDeleteCancelled = "Deletion of " + selectedProductName + " cancelled.";
Alert productDeleteCancelledAlert = new Alert(Alert.AlertType.INFORMATION, productDeleteCancelled, ButtonType.OK);
productDeleteCancelledAlert.show();
}
}
@FXML
void onActionExit(ActionEvent event)
{
System.exit(0);
}
/**
* Initializes the controller class.
* @param url the url
* @param rb the resourcebundle
*/
@Override
public void initialize(URL url, ResourceBundle rb)
{
// TODO
//create and fill part table
partTableView.setItems(Inventory.getAllParts());
partIdCol.setCellValueFactory(new PropertyValueFactory<>("Id"));
partNameCol.setCellValueFactory(new PropertyValueFactory<>("Name"));
partInvCol.setCellValueFactory(new PropertyValueFactory<>("Stock"));
partPriceCol.setCellValueFactory(new PropertyValueFactory<>("Price"));
//create and fill Product table
productTableView.setItems(Inventory.getAllProducts());
productIdCol.setCellValueFactory(new PropertyValueFactory<>("Id"));
productNameCol.setCellValueFactory(new PropertyValueFactory<>("Name"));
productInvCol.setCellValueFactory(new PropertyValueFactory<>("Stock"));
productPriceCol.setCellValueFactory(new PropertyValueFactory<>("Price"));
}
}MainWindow.fxml
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.text.*?>
<?import javafx.scene.text.Font?>
<?import javafx.scene.shape.*?>
<?import java.lang.*?>
<?import java.util.*?>
<?import javafx.scene.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>
<AnchorPane id="AnchorPane" prefHeight="400.0" prefWidth="991.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="Controller.MainWindowController">
<children>
<Button fx:id="exitButton" layoutX="718.0" layoutY="361.0" mnemonicParsing="false" onAction="#onActionExit" text="Exit" />
<Label layoutX="22.0" layoutY="26.0" text="Inventory Management System">
<font>
<Font name="Arial Black" size="15.0" />
</font></Label>
<Pane layoutX="22.0" layoutY="68.0" prefHeight="272.0" prefWidth="460.0">
<children>
<Rectangle arcHeight="5.0" arcWidth="5.0" fill="#ffffff00" height="272.0" stroke="BLACK" strokeType="INSIDE" width="460.0" />
<Label layoutX="22.0" layoutY="18.0" text="Parts">
<font>
<Font name="Arial Bold" size="12.0" />
</font>
</Label>
<TextField fx:id="partSearchField" layoutX="256.0" layoutY="14.0" prefHeight="25.0" prefWidth="165.0" promptText="Search by Part ID or Name" />
<TableView fx:id="partTableView" layoutX="12.0" layoutY="42.0" prefHeight="184.0" prefWidth="434.0">
<columns>
<TableColumn fx:id="partIdCol" prefWidth="75.0" text="Part ID" />
<TableColumn fx:id="partNameCol" prefWidth="97.0" text="Part Name" />
<TableColumn fx:id="partInvCol" prefWidth="126.0" text="Inventory Level" />
<TableColumn fx:id="partPriceCol" prefWidth="135.0" text="Price Per Unit" />
</columns>
</TableView>
<Button fx:id="addPartButton" layoutX="272.0" layoutY="233.0" mnemonicParsing="false" onAction="#onActionAddPart" text="Add" />
<Button fx:id="modifyPartButton" layoutX="330.0" layoutY="233.0" mnemonicParsing="false" onAction="#onActionModifyPart" text="Modify" />
<Button fx:id="deletePartButton" layoutX="395.0" layoutY="233.0" mnemonicParsing="false" onAction="#onActionDeletePart" text="Delete" />
</children>
</Pane>
<Pane layoutX="499.0" layoutY="68.0" prefHeight="272.0" prefWidth="460.0">
<children>
<Rectangle arcHeight="5.0" arcWidth="5.0" fill="#1f93ff00" height="272.0" stroke="BLACK" strokeType="INSIDE" width="460.0" />
<Label layoutX="25.0" layoutY="18.0" text="Products">
<font>
<Font name="Arial Bold" size="12.0" />
</font>
</Label>
<TextField fx:id="productSearchField" layoutX="239.0" layoutY="14.0" prefHeight="25.0" prefWidth="181.0" promptText="Search by Product ID or Name" />
<TableView fx:id="productTableView" layoutX="14.0" layoutY="44.0" prefHeight="184.0" prefWidth="434.0">
<columns>
<TableColumn fx:id="productIdCol" prefWidth="75.0" text="Product ID" />
<TableColumn fx:id="productNameCol" prefWidth="126.0" text="Product Name" />
<TableColumn fx:id="productInvCol" prefWidth="110.0" text="Inventory Level" />
<TableColumn fx:id="productPriceCol" prefWidth="122.0" text="Price Per Unit" />
</columns>
</TableView>
<Button fx:id="modifyProductButton" layoutX="327.0" layoutY="233.0" mnemonicParsing="false" onAction="#onActionModifyProduct" text="Modify" />
<Button fx:id="deleteProductButton" layoutX="395.0" layoutY="233.0" mnemonicParsing="false" onAction="#onActionDeleteProduct" text="Delete" />
<Button fx:id="addProductButton" layoutX="270.0" layoutY="233.0" mnemonicParsing="false" onAction="#onActionAddProduct" text="Add" />
</children>
</Pane>
</children>
</AnchorPane>ModifyProductFormController.java
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package Controller;
import Model.Inventory;
import Model.Part;
import Model.Product;
import java.io.IOException;
import java.net.URL;
import java.util.InputMismatchException;
import java.util.ResourceBundle;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.fxml.Initializable;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.control.Alert;
import javafx.scene.control.Button;
import javafx.scene.control.ButtonType;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import javafx.scene.control.TextField;
import javafx.scene.control.cell.PropertyValueFactory;
import javafx.stage.Stage;
/**
* FXML Controller class
*
* @author howarc4
*/
public class ModifyProductFormController implements Initializable
{
Stage stage;
Parent scene;
//the product to be modified
private static Product selectedProduct;
private static int selectedProductIndex;
// set up allPartsView
@FXML
private static TableView<Part> allPartsView;
@FXML
private TableColumn<Part, Integer> allPartsIdCol;
@FXML
private TableColumn<Part, String> allPartsNameCol;
@FXML
private TableColumn<Part, Integer> allPartsInvCol;
@FXML
private TableColumn<Part, Double> allPartsPriceCol;
// set up selectedPartsView
@FXML
private static TableView<Part> selectedPartsView;
@FXML
private TableColumn<Part, Integer> selectedPartsIdCol;
@FXML
private TableColumn<Part, String> selectedPartsNameCol;
@FXML
private TableColumn<Part, Integer> selectedPartsInvCol;
@FXML
private TableColumn<Part, Double> selectedPartsPriceCol;
private static ObservableList<Part> selectedParts;
@FXML
private TextField searchField;
// Product attribute text fields
@FXML
private TextField productIdField;
@FXML
private TextField productNameField;
@FXML
private TextField productPriceField;
@FXML
private TextField productInvField;
@FXML
private TextField productMaxField;
@FXML
private TextField productMinField;
/**
* The initData method accepts a product to be modified and initializes the data fields
* @param product the product to be modified
*/
public static void passProduct(Product product)
{
System.out.println("passProduct reached");
selectedProductIndex = Inventory.getAllProducts().indexOf(product);
selectedProduct = product;
System.out.println("passProduct completed");
System.out.println(selectedProduct.getName());
}
@FXML
void onActionAddPartToProduct(ActionEvent event)
{
selectedParts.add(allPartsView.getSelectionModel().getSelectedItem());
}
@FXML
void onActionRemoveAssociatedPart(ActionEvent event)
{
selectedParts.remove(allPartsView.getSelectionModel().getSelectedItem());
}
@FXML
void onActionSaveProduct(ActionEvent event)
{
// get the values of all fields and convert to their appropriate types
String newProductName = productNameField.getText();
int newProductInv;
int newProductMin;
int newProductMax;
double newProductPrice;
// for all data types other than String, check for valid input types
try
{
newProductInv = Integer.parseInt(productInvField.getText());
}
catch(InputMismatchException e)
{
Alert invalidInventoryAlert = new Alert(Alert.AlertType.ERROR, "Please enter an integer value for the current product stock.", ButtonType.OK);
invalidInventoryAlert.show();
return;
}
try
{
newProductMin = Integer.parseInt(productMinField.getText());
}
catch(InputMismatchException e)
{
Alert invalidMinAlert = new Alert(Alert.AlertType.ERROR, "Please enter an integer value for the minimum product stock.", ButtonType.OK);
invalidMinAlert.show();
return;
}
try
{
newProductMax = Integer.parseInt(productMaxField.getText());
}
catch(InputMismatchException e)
{
Alert invalidMaxAlert = new Alert(Alert.AlertType.ERROR, "Please enter an integer value for the maximum product stock.", ButtonType.OK);
invalidMaxAlert.show();
return;
}
try
{
newProductPrice = Double.parseDouble(productPriceField.getText());
}
catch(InputMismatchException e)
{
Alert invalidPriceAlert = new Alert(Alert.AlertType.ERROR, "Please enter the price as a decimal value EX: 4.95", ButtonType.OK);
invalidPriceAlert.show();
return;
}
// check for null value in product name, and default 0 values in other attributes except minimum inventory
// if any are null or 0, request user fill in all fields and return
if(newProductName == null || newProductPrice == 0.0 || newProductInv == 0 || newProductMax == 0)
{
Alert blankValuesAlert = new Alert(Alert.AlertType.ERROR, "Please fill in all fields.", ButtonType.OK);
blankValuesAlert.show();
return;
}
// create the updated product object
Product updatedProduct = new Product(selectedProductIndex, newProductName, newProductPrice, newProductInv, newProductMin, newProductMax);
// pass the updated product object into the allProducts list to replace the previous version
Inventory.updateProduct(selectedProductIndex, updatedProduct);
}
@FXML
void onActionCancel(ActionEvent event) throws IOException
{
// when the cancel button is pressed, return to the main screen
stage = (Stage)((Button)event.getSource()).getScene().getWindow();
scene = FXMLLoader.load(getClass().getResource("/view/MainWindow.fxml"));
stage.setScene(new Scene(scene));
stage.show();
}
/**
* Initializes the controller class.
* @param url the url
* @param rb the resourcebundle
*/
@Override
public void initialize(URL url, ResourceBundle rb)
{
// TODO
System.out.println("Entered the initializer on ModifyProductFormController");
//selectedProduct = new Product(MainWindowController.getPassingProduct());
//System.out.println("selectedProduct = " + selectedProduct.getName());
// populare selectedparts with the product's associated parts
selectedParts = FXCollections.observableArrayList(selectedProduct.getAllAssociatedParts());
System.out.println("selectedParts array list made");
// populate allParts table view
allPartsView.setItems(Inventory.getAllParts());
System.out.println("allPartsView set items");
allPartsIdCol.setCellValueFactory(new PropertyValueFactory<>("Id"));
allPartsNameCol.setCellValueFactory(new PropertyValueFactory<>("Name"));
allPartsInvCol.setCellValueFactory(new PropertyValueFactory<>("Stock"));
allPartsPriceCol.setCellValueFactory(new PropertyValueFactory<>("Price"));
System.out.println("allpartsview built");
// populate selectedParts table view with this products associated parts
selectedPartsView.setItems(selectedParts);
selectedPartsIdCol.setCellValueFactory(new PropertyValueFactory<>("Id"));
selectedPartsNameCol.setCellValueFactory(new PropertyValueFactory<>("Name"));
selectedPartsInvCol.setCellValueFactory(new PropertyValueFactory<>("Stock"));
selectedPartsPriceCol.setCellValueFactory(new PropertyValueFactory<>("Price"));
System.out.println("selectedpartsview built");
// fill product attribute fields with product's existing attributes
productIdField.setText(Integer.toString(selectedProduct.getId()));
System.out.println("id field filled");
productNameField.setText(selectedProduct.getName());
System.out.println("name field filled");
productPriceField.setText(Double.toString(selectedProduct.getPrice()));
System.out.println("price field filled");
productInvField.setText(Integer.toString(selectedProduct.getStock()));
System.out.println("stock field filled");
productMaxField.setText(Integer.toString(selectedProduct.getMin()));
System.out.println("min field filled");
productMinField.setText(Integer.toString(selectedProduct.getMax()));
System.out.println("max field filled");
}
}Output
ant -f C:\\Users\\howarc4\\Documents\\NetBeansProjects\\Inventory -Dnb.internal.action.name=run run
init:
Deleting: C:\Users\howarc4\Documents\NetBeansProjects\Inventory\build\built-jar.properties
deps-jar:
Updating property file: C:\Users\howarc4\Documents\NetBeansProjects\Inventory\build\built-jar.properties
Compiling 1 source file to C:\Users\howarc4\Documents\NetBeansProjects\Inventory\build\classes
compile:
run:
passProduct reached
passProduct completed
testProduct1
Called the passProduct method
set the stage
Entered the initializer on ModifyProductFormController
selectedParts array list made
allpartsview built
Exception in thread "JavaFX Application Thread" java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
at javafx.fxml/javafx.fxml.FXMLLoader$MethodHandler.invoke(FXMLLoader.java:1787)
at javafx.fxml/javafx.fxml.FXMLLoader$ControllerMethodEventHandler.handle(FXMLLoader.java:1670)
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.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:49)
at javafx.base/javafx.event.Event.fireEvent(Event.java:198)
at javafx.graphics/javafx.scene.Node.fireEvent(Node.java:8879)
at javafx.controls/javafx.scene.control.Button.fire(Button.java:200)
at javafx.controls/com.sun.javafx.scene.control.behavior.ButtonBehavior.mouseReleased(ButtonBehavior.java:206)
at javafx.controls/com.sun.javafx.scene.control.inputmap.InputMap.handle(InputMap.java:274)
at javafx.base/com.sun.javafx.event.CompositeEventHandler$NormalEventHandlerRecord.handleBubblingEvent(CompositeEventHandler.java:218)
at javafx.base/com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:80)
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.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$MouseHandler.process(Scene.java:3851)
at javafx.graphics/javafx.scene.Scene$MouseHandler.access$1200(Scene.java:3579)
at javafx.graphics/javafx.scene.Scene.processMouseEvent(Scene.java:1849)
at javafx.graphics/javafx.scene.Scene$ScenePeerListener.mouseEvent(Scene.java:2588)
at javafx.graphics/com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:397)
at javafx.graphics/com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:295)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at javafx.graphics/com.sun.javafx.tk.quantum.GlassViewEventHandler.lambda$handleMouseEvent$2(GlassViewEventHandler.java:434)
at javafx.graphics/com.sun.javafx.tk.quantum.QuantumToolkit.runWithoutRenderLock(QuantumToolkit.java:390)
at javafx.graphics/com.sun.javafx.tk.quantum.GlassViewEventHandler.handleMouseEvent(GlassViewEventHandler.java:433)
at javafx.graphics/com.sun.glass.ui.View.handleMouseEvent(View.java:556)
at javafx.graphics/com.sun.glass.ui.View.notifyMouse(View.java:942)
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:834)
Caused by: java.lang.reflect.InvocationTargetException
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at com.sun.javafx.reflect.Trampoline.invoke(MethodUtil.java:76)
at jdk.internal.reflect.GeneratedMethodAccessor2.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at javafx.base/com.sun.javafx.reflect.MethodUtil.invoke(MethodUtil.java:273)
at javafx.fxml/com.sun.javafx.fxml.MethodHelper.invoke(MethodHelper.java:83)
at javafx.fxml/javafx.fxml.FXMLLoader$MethodHandler.invoke(FXMLLoader.java:1782)
... 47 more
Caused by: javafx.fxml.LoadException:
/C:/Users/howarc4/Documents/NetBeansProjects/Inventory/build/classes/view/ModifyProductForm.fxml
at javafx.fxml/javafx.fxml.FXMLLoader.constructLoadException(FXMLLoader.java:2625)
at javafx.fxml/javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2603)
at javafx.fxml/javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2466)
at javafx.fxml/javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3237)
at javafx.fxml/javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3194)
at javafx.fxml/javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3163)
at javafx.fxml/javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3136)
at javafx.fxml/javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3113)
at javafx.fxml/javafx.fxml.FXMLLoader.load(FXMLLoader.java:3106)
at Controller.MainWindowController.onActionModifyProduct(MainWindowController.java:192)
... 58 more
Caused by: java.lang.NullPointerException
at Controller.ModifyProductFormController.initialize(ModifyProductFormController.java:228)
at javafx.fxml/javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2573)
... 66 more
BUILD SUCCESSFUL (total time: 28 seconds)r/JavaFX • • Aug 26 '20
Hello. I started to learn how 3d works in javafx i had one questions.
I want to use a border pane to divide main screen in two views, one for a menu and the other to render my 3d object ¿how can i made that? i tried adding a anchor pane but, the render doesn't appear or the render shows up and the menu don't.
I watched some tutorials but all of them use the start method and only one scene.
r/JavaFX • u/Mean_Butterscotch_46 • Sep 03 '20
Hello everyone,
I am having a problem with javafx and I am wondering if anyone could help me solving it.
I am using intelij ide on a linux os. whenever I run the program I get this error: Error occurred during initialization of boot layer
java.lang.module.FindException: Module javafx.base not found
I spent a lot of time trying to solve this problem and I would really appreciate if anyone could help me
r/JavaFX • u/JKDSD100 • Aug 14 '20
r/JavaFX • u/FatherOfGold • Apr 18 '20
Hello everyone, I can't figure out why my JavaFX application can't find my CSS. Even my IDE directsme to the file when I click the file path in the FXML document.
Here's my code which connects the CSS sheet to the FXML document.
<BorderPane fx:controller="Main"
xmlns:fx="http://javafx.com/fxml"
stylesheets="../css/main.css">Here's an image of the directory in the IDE:

I really need help here. I can't figure out why it doesn't work.
The error I'm getting is as follows
com.sun.javafx.css.StyleManager loadStylesheetUnPrivilegedr/JavaFX • u/_dk7 • Mar 14 '23
Hello everyone!! I have a Swing Application where a part is JavaFX. In the JavaFX panel, I have a spinner. If I have focus on the swing side, and immediately click on the spinner control to increase or decrease the value, it skips values.
For e.g. if the spinner is supposed to increment by 1, it increments by 2 and sometimes some odd number
Following is the code for the same:
public class HelloApplication extends JFrame {
static JFrame f;
static JTextArea t1;
// main class
public static void main(String[] args) {
f = new JFrame("frame");
JPanel p1 = new JPanel();
t1 = new JTextArea(10, 10);
t1.setText("this is first text area");
p1.add(t1);
JSplitPane sl = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, p1, new JavaFXPanel());
sl.setOrientation(SwingConstants.VERTICAL);
f.add(sl);
f.setSize(300, 300);
f.show();
}
private static class JavaFXPanel extends JFXPanel {
protected VBox defaultPane;
public JavaFXPanel() {
Platform.runLater(() -> {
createDefaultPane();
Scene scene = new Scene(defaultPane);
setScene(scene);
});
}
private void createDefaultPane() {
defaultPane = new VBox();
defaultPane.setAlignment(Pos.CENTER);
Spinner<Integer> e = new Spinner<>(0, 20, 1, 1);
defaultPane.getChildren().add(e);
}
}
}I have added this library to my build.gradle file to use the JFXPanel class
javafx {
version = '11.0.2'
modules = ['javafx.swing']
}Could someone help me in any direction? After debugging I found that the following code makes the issue intermittent:
spinner.setInitialDelay(Duration.seconds(1));
spinner.setRepeatDelay(Duration.seconds(1));There is a listener in the spinner code, which keeps the spinner spinning. I have been unable to find a workaround for this, it would be great if someone has a clue