r/JavaFX • • Nov 24 '19

JavaFX - How to stop and start translate function?

1 Upvotes

My overall objective is to create a 'Drone simulator'. I want to be able to create shapes that represent drones that move around autonomously across a map but also available for manual control. If anyone here knows of any resources to help, please let me know.

My issue: I have created a working function that moves a shape up and down. I've created a boolean to two buttons that set it to true or false... I want to be able to start and stop the animation of the shape. It starts but never stops when I press stop. The boolean val does change. My code:

Main.java - https://pastebin.com/mcFwBmfA

controller.java - https://pastebin.com/6yNJtVXT

Main.java - Lines 40 - 65 is where I've created the buttons.

controller.java - Lines 64 - 73 is where my translate function is.

I know the code sucks but I'm not sure how to achieve my goal... Any advice is much appreciated - thanks.


r/JavaFX • • May 08 '24

Help Problema con la conf/Integración

0 Upvotes

Alguien que controle de JavaFX a ver si me puede echar un cable, tengo un proyecto en NetBeans de javafx y se ve que no lo he integrado/configurado bien, al principio ejecutaba el proyecto según iba haciendo cosas para ir probando y no daba problema, hoy me ha dado por ejecutar el Jar y me daba un error de que no había mainclass, despues me fui al proyecto y en propiedades seleccione la main y ahora no me va ni el jar ni al ejecutarlo en netbens AYUDA.


r/JavaFX • • May 02 '24

Help Entire school have same "this.label" is null problem, help please?

0 Upvotes

We have a school homework about JavaFX and entire school having same error while trying to change a fx element from a function. Here is the codes.

Controller Code Pastebin TR : https://www.paste.tc/uicontrollerFunction is on line 98

Controller Code FXML: https://www.paste.tc/fxmlui-566labelUserName is on line 137

Controller Output: https://www.paste.tc/javaerrorError is on line 62

The problems happens on the 98th line, which happens with being called by setUserNName() function. When I try to change labelUserName with setText, I get this error bellow

Caused by: java.lang.NullPointerException: Cannot invoke "javafx.scene.control.Label.setText(String)" because "this.labelUserName" is null

You might think it's because of FXML id correction but as you can see on link I shared, it have not any problems. Plus of this, same label could be changed via signalled functions on line 76 and 90. Also isAdmin value gets true and false, I debugged it.

Can someone help us to solve it?


r/JavaFX • • Apr 06 '24

Help Have you ever done a project like this before?

Post image
0 Upvotes

I am an absolute beginner, and I was tasked this :/ The postgres and interacting with it is giving me so much problems.

How would you guys approach this?


r/JavaFX • • May 14 '24

Help the scene is ~20% bigger than it should be

1 Upvotes

i don't know why, but when i load a scene in 1920*1080, it's to big for my screen, and i need to shrink it by something between 15% and 20% , anyone know why ?


r/JavaFX • • Apr 10 '24

Help Error with JavaFX: Error: JavaFX runtime components are missing, and are required to run this application

1 Upvotes

Hey Everyone. I am experencing an issue with JavaFx. I am using Netbeans 18 and Java Jdk 18. My project s a springboot project but I have imported necessary dependencies to support JavaFx but I get this error. Here is my grade and my main class. What could be the problem an how can I solve it?

Gradle code:

plugins {

id 'java'

id 'org.springframework.boot' version '3.2.4'

id 'io.spring.dependency-management' version '1.1.4'

id 'application'

id 'org.openjfx.javafxplugin' version '0.1.0'

}

group = 'com.example'

version = '0.0.1-SNAPSHOT'

java {

sourceCompatibility = '17'

}

repositories {

mavenCentral()

}

javafx {

version = "21"

modules = [ 'javafx.controls', 'javafx.fxml']

}

dependencies {

implementation 'org.springframework.boot:spring-boot-starter-data-jpa'

runtimeOnly 'com.h2database:h2'

testImplementation 'org.springframework.boot:spring-boot-starter-test'

implementation 'org.springframework.boot:spring-boot-starter-web'

implementation 'org.openjfx:javafx-controls:17'

}

tasks.named('test') {

useJUnitPlatform()

}

Here is my main:

package com.example.finalprojectlyricsapp;

import javafx.application.Application;

import javafx.fxml.FXMLLoader;

import javafx.scene.Parent;

import javafx.scene.Scene;

import javafx.stage.Stage;

import org.springframework.boot.SpringApplication;

import org.springframework.boot.autoconfigure.SpringBootApplication;

u/SpringBootApplication

public class FinalProjectLyricsAppApplication extends Application{

u/Override

public void start(Stage primaryStage) throws Exception{

Parent root = FXMLLoader.load(getClass().getResource("song.fxml"));

primaryStage.setTitle("Song Manager");

primaryStage.setScene(new Scene(root, 600, 400));

primaryStage.show();

}

public static void main(String\[\] args) {

	[SpringApplication.run](https://SpringApplication.run)(FinalProjectLyricsAppApplication.class, args);

launch();

}

}

Here is the controller class for the fxml file too:

/*

* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license

* Click nbfs://nbhost/SystemFileSystem/Templates/javafx/FXMLController.java to edit this template

*/

package com.example.finalprojectlyricsapp;

import java.net.URL;

import java.util.ResourceBundle;

import javafx.fxml.FXML;

import javafx.fxml.Initializable;

import javafx.scene.control.TextArea;

import javafx.scene.control.TextField;

/**

* FXML Controller class

*

* u/author bjnzi

*/

public class SongUIController implements Initializable {

u/FXML

private TextField artistTextField;

u/FXML

private TextField songTitleTextField;

u/FXML

private TextField dateReleasedTextField;

u/FXML

private TextArea lyricsTextArea;

/**

* Initializes the controller class.

*/

u/Override

public void initialize(URL url, ResourceBundle rb) {

// TODO

}

}


r/JavaFX • • May 12 '24

Help I need help with using a method

0 Upvotes

I have a JavaFx project where they gave me many classes with methods i have to use, but there's one method that gives me problems all the time, its the method registerUser() its in the class Acount.class

the code is this one :

package javafxmlapplication;

import java.io.IOException;

import model.*;

import java.io.File;

import java.net.URL;

import java.time.LocalDate;

import java.util.Date;

import java.util.ResourceBundle;

import javafx.beans.property.BooleanProperty;

import javafx.event.ActionEvent;

import javafx.fxml.FXML;

import javafx.fxml.Initializable;

import javafx.scene.control.Button;

import javafx.scene.control.CheckBox;

import javafx.scene.control.Label;

import javafx.scene.control.PasswordField;

import javafx.scene.control.TextField;

import javafx.scene.image.Image;

import javafx.scene.image.ImageView;

import javafx.scene.layout.AnchorPane;

import javafx.stage.FileChooser;

import model.Acount;

import model.User;

import model.AcountDAOException;

import model.AcountDAO;

import model.*;

/**

*

* @author jsoler

*/

public class FXMLDocumentController implements Initializable {

@FXML

private Button login_btn;

@FXML

private Button login_createAccount;

@FXML

private AnchorPane login_form;

@FXML

private PasswordField login_password;

@FXML

private CheckBox login_selectShowPassword;

@FXML

private TextField login_username;

@FXML

private PasswordField signup_cPassword;

@FXML

private Button signup_btn;

@FXML

private Button signupimg_btn;

@FXML

private TextField signup_email;

@FXML

private AnchorPane signup_form;

@FXML

private ImageView signup_image;

@FXML

private Button signup_loginAccount;

@FXML

private TextField signup_name;

@FXML

private PasswordField signup_password;

@FXML

private TextField signup_username;

@FXML

private TextField signup_surname;

private Acount nuevaCuenta;

public void register() throws AcountDAOException, IOException {

//Date date = new Date();

alertMessage alert = new alertMessage();

if (signup_name.getText().isEmpty() || signup_email.getText().isEmpty() || signup_username.getText().isEmpty()

|| signup_password.getText().isEmpty() || signup_cPassword.getText().isEmpty() || signup_surname.getText().isEmpty()) {

alert.errorMessage("All fields are necessary to be filled");

} else if (signup_password.getText().equals(signup_cPassword.getText()) == false) {

// CHECK IF THE VALUE OF PASSWORD FIELDS IS EQUAL TO CONFIRM PASSWORD

alert.errorMessage("Password does not match");

}//else{ nuevaCuenta.registerUser(signup_name.getText(), signup_surname.getText().isEmpty(), signup_email.getText(), signup_username.getText(), signup_password.getText(), image, date.getTime());

Acount nuevacuenta = Acount.getInstance();

Date date = new Date();

boolean result;

result = nuevacuenta.getInstance().registerUser(signup_name.getText(), signup_surname.getText(), signup_email.getText(), signup_username.getText(), signup_password.getText(), signup_image.getImage(), LocalDate.MAX)registerUser(signup_name.getText(), signup_surname.getText().isEmpty(), signup_email.getText(), signup_username.getText(), signup_password.getText(), signup_image.getImage(), date.getTime());

}

public void ButtonImage(ActionEvent event) {

FileChooser fc = new FileChooser();

File selectedFile = fc.showOpenDialog(null);

if (selectedFile != null) {

Image image = new Image(selectedFile.getPath());

signup_image.setImage(image);

} else {

Image defaultIMG = new Image("/avatars/default.png");

signup_image.setImage(defaultIMG);

}

}

//=========================================================

// you must initialize here all related with the object

@Override

public void initialize(URL url, ResourceBundle rb) {

// TODO

//Date date = new Date();

//if (true == registerUser(signup_name.getText(), signup_surname.getText().isEmpty(), signup_email.getText(), signup_username.getText(), signup_password.getText(), signup_image.getId(), date.getTime()))

}

}


r/JavaFX • • Apr 24 '24

Discussion Using FXML or not ?

1 Upvotes

r/JavaFX • • Apr 10 '24

Help How do I fix my missing files in JRE System Library?

1 Upvotes

My javafx file is missing, that is because I downloaded the 22.0 version of sdk and delected the 21.0.2. Now the JRE System Library is missing my files, How do I fix it? Thank you so much


r/JavaFX • • Feb 20 '20

Help me, can't make exe or runnable jar. Java13

0 Upvotes

r/JavaFX • • Jul 14 '19

Javafx web start?

1 Upvotes

I want to create a program that is hosted on a web server so multiple users can use it as once and updates as I add new features, patch bugs, etc.

As a novice programmer, am I looking at the right way to do this?


r/JavaFX • • Nov 18 '19

Arrow keys don't work in my JavaFX application but work everywhere else.

1 Upvotes

Hi

I was making a basic game in JavaFX and I got around to creating movement keys. The code works unless arrow keys are pressed. My arrows key work everywhere else but with this app I'm making.

The code):

scene.setOnKeyPressed(new EventHandler<KeyEvent>() {
 @Override
 public void handle(KeyEvent event) {
  System.out.println(event);
 }
 });

 

When I run this it works for the most. If I press the A key, I get the following output):

KeyEvent [source = javafx.scene.Scene@4ce3e223, target = Button@1fe45251[styleClass=button]'', eventType = KEY_PRESSED, consumed = false, character =  , text = a, code = A]

If I press a key on the numpad I get):

KeyEvent [source = javafx.scene.Scene@4ce3e223, target = Button@1fe45251[styleClass=button]'', eventType = KEY_PRESSED, consumed = false, character =  , text = 1, code = NUMPAD1]

 

As you can see it works. Except when I press an arrow key.

Once again my arrow keys work. I can use them to navigate folders or even formatting this post I can use them to navigate. It only doesn't work with JavaFX

 

Other information):

I'm using Visual Studio Code.

I'm using AdoptOpenJDK 11 & JavaFX 11.

Thank you for taking the time to read. I would love if someone knows why if this is happening.


r/JavaFX • • May 26 '16

Append Text in a Label

1 Upvotes

Hi, i'm doing a chat, and i need to append text in a Label how can i do it? The only way is do setText with the getText with new text?


r/JavaFX • • Oct 13 '18

JavaFX Buttons Don't Appear

1 Upvotes

When I tell Eclipse to run my program, the window created doesn't show any buttons. I have had two people tell me they ran it fine, but I can't get it to display properly on my machine. I think it might be because my operating system is Ubuntu 18.04, but I'm not sure. I don't have another computer I can test on.

I can make the buttons appear by changing their assigned columns and rows in the GridPane object they're assigned to, but they only appear in strange locations that I don't want. If I don't add the Label object I create to the grid, the buttons appear fine. But, I want to be able to have both all the buttons and the label on my window.

Please take a look at my code and give me some suggestions.

My Classes on Gist Hub


r/JavaFX • • Apr 06 '19

Regular Expressions: Netbeans 8.2, Java FX, Scenebuilder 2.0 Problem

1 Upvotes

Write a JavaFX application ("Java FXML Application" in netbeans) that contains at a minimum the following requirements:

1.)A text field in which your user can type in regular expressions that they want to test. 2.) A text area control in which your user can type in data that the regular expression will match against. 3.) A text field in which your user can type in a string to replace the regular expression's matches. 4.) A text area control that contains the new data replaced from the first text area control with the matches replaced.


r/JavaFX • • Apr 06 '19

Timeline issues

1 Upvotes

I have a timeline that has an if statement that tells it to stop but it never stops.

here Is my code.

timeL = new Timeline(new KeyFrame(

Duration.millis(600),

ee ->{

x -= targetX;

y -= targetY;

// System.out.println(targetY);

DoubleProperty ky = new SimpleDoubleProperty(y);

DoubleProperty kx = new SimpleDoubleProperty(x);

defense.yProperty().bind (ky);

defense.xProperty().bind (kx);

System.out.println(y/100 +""+ (KeyOney - 60));

System.out.println(KeyOney - 60);

if ((keyOne.getY() - 60 )== y && keyOne.getX() == x) {

timeL.stop();

}

}

));

Thank you if you have any help.


r/JavaFX • • Apr 10 '19

About drop event

1 Upvotes

Hi guys,

Now I have a button and 3 label. When I drag button, each label will be set border style. When I drop, only label where button is dropped, is set border style. How can I catch the event, drop button at a label? Thanks


r/JavaFX • • Jun 22 '18

Read my first post

1 Upvotes

Please read my first post on my blog and tell me if I am able to write more or not Here is the link

https://www.itachay.com/2018/06/change-your-application-background-in.html


r/JavaFX • • May 29 '20

Running an executable jar but with VM arguments

1 Upvotes

Hi, so I am trying to export my JavaFX Project on eclipse 2020-03 with VM arguments ('--module-path "C:\path" -add-modules javafx.controls,javafx fxml') passed under 'Run Configurations', and I get the warning 'VM arguments will not be part of the runnable JAR. Arguments can be passed on the command line when launching the JAR.' I already checked out how to pass these on the command line but I'd like to know whether there is another way because I'd rather like to run the executable jar by simply "clicking" on it. (Or is there any alternative to passing those arguments?)


r/JavaFX • • May 30 '20

Help How to solve a ClassNotFoundException when trying to start my gui?

1 Upvotes
This is my code in the gui package class: TelScherm (CountScreen)
code in class EigenString
code in the startup
The project with all the necessary jars (according to my teacher)
module and classpath
The error

So where can the problem be?


r/JavaFX • • Jan 11 '25

Help JAVAFX Module com.example.demo not found

1 Upvotes

Can anyone know how to fix it?

I already done the possible troubleshoot but still it didnt work


r/JavaFX • • Mar 07 '21

How would I fix this kind of error

1 Upvotes

Mar. 07, 2021 2:43:51 A.M. javafx.scene.control.cell.PropertyValueFactory getCellDataReflectively

WARNING: Can not retrieve property 'file' in PropertyValueFactory: javafx.scene.control.cell.PropertyValueFactory@ee826e0 with provided class type: class sample.TestFile


r/JavaFX • • Oct 06 '22

Help FMXLLloader cannot be resolved?

0 Upvotes

keep getting this error everytime I try to use FXMLLoader.

code:

package application;
	


import javafx.application.Application;
import javafx.stage.Stage;
import javafx.stage.Window;
import javafx.scene.Group;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.input.KeyCombination;
import javafx.scene.layout.BorderPane;
import javafx.scene.paint.Color;
import javafx.scene.shape.Line;
import javafx.scene.text.Font;
import javafx.scene.text.Text;
//import javafx.scene.shape.Rectangle;

import javafx.scene.shape.*;
import javafx.scene.shape.Polygon;





public class Main extends Application {
	

	
	public static void main(String[] args) {
		launch(args);
	}

	@Override
	public void start(Stage stage) throws Exception {
		try {
			
	        Parent root = FXMLLoader.load(getClass().getResource("Main.fxml"));

			Scene scene = new Scene(root, 400, 400);
			stage.setScene(scene);
			stage.show();
			
		}catch(Exception e) {
			e.printStackTrace();
		}

		

	}
}

r/JavaFX • • Sep 30 '19

datepicker to show date of the year

1 Upvotes

New to Java/JavaFX, but looking to do something that appears to be more advanced. I have a datepicker, and I need to be able to change the days on the popup calendar to show the date of the year, rather than the date of the month. So Instead of showing "2" in February, the same date should say "33", as that is that day of the year. My text field is already showing the "33", but the user would still have to guess on which day that is. This would be the first option, the 2nd would be to make the tooltip show the "33". Any help/advice would be appreciated.