javafx

Understanding how the main class affects JPMS

痞子三分冷 提交于 2020-07-06 11:05:53
问题 I have a very basic JavaFX application that works flawlessly if the Application class is not the Main class: import javafx.application.Application; import javafx.fxml.FXMLLoader; import javafx.stage.Stage; public class Main { public static void main(String[] args) { Application.launch(App.class, args); } } public class App extends Application { @Override public void start(Stage primaryStage) { FXMLLoader loader = new FXMLLoader(); // works } } However, when I merge the two together (which is

JavaFX GridPane: Shrink if content is disabled and invisible

落花浮王杯 提交于 2020-07-04 03:28:12
问题 Is it possible to shrink a GridPane row if the content of that row is both disabled and invisible? When I set a Node to disable=true and visible=false, the cell still takes up space. If I have 8 rows and only the first and last is visible I don't want the empty rows to take up much space. As if there was only two rows. The only "solution" I could find was to set the size to zero. However I do not consider that a good solution. I would have to store the min/max size to set it back when/if the

JavaFX TextField text validation

ぃ、小莉子 提交于 2020-07-03 20:19:17
问题 I have a listener applied to my field: nameTextField.addEventHandler(KeyEvent.KEY_TYPED, fieldChangeListener(50)); Event handler: private EventHandler<KeyEvent> fieldChangeListener(final Integer max_Lengh) { return new EventHandler<KeyEvent>() { @Override public void handle(KeyEvent event) { TextField field = (TextField) event.getSource(); String text = field.getText(); // I need here something like: if(KeyEvent.VK_ENTER){ // do special part for ENTER KEY } } } } Problem is KeyEvent event is

How do I get multiple Java threads to pause and resume at a user's request?

五迷三道 提交于 2020-07-03 11:56:41
问题 I'm creating a 20-minute countdown timer application. I'm using JavaFX SceneBuilder to do this. The timer is composed of two labels (one for minutes, one for seconds--each composed of a CountdownTimer class object), and a progress bar (the timer looks like this). Each of these components are separate and running on separate threads concurrently to prevent the UI from freezing up. And it works. The problem: The three threads ( minutesThread , secondsThread , progressBarUpdaterThread ) I need

How do I get multiple Java threads to pause and resume at a user's request?

半城伤御伤魂 提交于 2020-07-03 11:56:09
问题 I'm creating a 20-minute countdown timer application. I'm using JavaFX SceneBuilder to do this. The timer is composed of two labels (one for minutes, one for seconds--each composed of a CountdownTimer class object), and a progress bar (the timer looks like this). Each of these components are separate and running on separate threads concurrently to prevent the UI from freezing up. And it works. The problem: The three threads ( minutesThread , secondsThread , progressBarUpdaterThread ) I need

JavaFX InvalidationListener or ChangeListener

為{幸葍}努か 提交于 2020-07-02 18:35:13
问题 I am only interested whether a property has changed or not, but not in the new value. Is it advantageous to register an InvalidationListener instead of a ChangeListener ? I was assuming that a change to a property does first invalidate the property and notifies all invalidation listeners. Only if there are change listeners registered, or somebody requests this property, the property is 'validated'/ re-computed and all change listeners are updated with the new value. Since I am not interested

Styling of subelement of RadioButton in JavaFX using CSS

烂漫一生 提交于 2020-06-29 09:49:17
问题 I'm trying to change the appearance of the RadioButton in JavaFX by using CSS, but facing the problem. According to the JavaFX CSS Reference Guide element structure consists of subelements: radio — Region dot — Region label — Label Subelement radio stylized in modena.css: .radio-button > .radio, .radio-button:focused > .radio { -fx-background-radius: 1.0em; -fx-padding: 0.333333em; } By overriding these style classes are configurable appearance of subelement. Sub .dot stylized too. But... if

Java IllegalAccessError can't run Application

此生再无相见时 提交于 2020-06-29 06:22:31
问题 I'm setting up my first program for a class and I'm stuck on why my program won't run trying to debug. What do I need to do to debug this error? I've tried to add libraries but this didn't seem to work. import javafx.event.ActionEvent; import javafx.event.EventHandler; import javafx.scene.Parent; import javafx.scene.Scene; import java.io.IOException; import javafx.fxml.FXMLLoader; import javafx.scene.control.Button; import javafx.scene.layout.StackPane; import javafx.stage.Stage; import java

JavaFX (with FXML) Adding Action events for buttons

倾然丶 夕夏残阳落幕 提交于 2020-06-29 04:36:05
问题 I have a FXML-File build with Scene-Builder with the needed fx:ids and the following controller: public class LaunchLogin extends Application{ public static void main (String [] args) { launch(args); } @Override public void start (Stage primaryStage) throws Exception { //ResourceLoader rl = ResourceLoader.getInstance(); FXMLLoader loader = new FXMLLoader(); loader.setLocation(getClass().getResource("/gfx/gui/LoginScreenUI.fxml")); Parent root = loader.load(); Scene scene = new Scene(root);

InvocationTargetException when binding to custom class run by JavaFX Concurrent Task

一世执手 提交于 2020-06-29 04:05:22
问题 I'm getting InvocationTargetException and NullPointerException when attempting to bind to custom class run by Task. I have working examples of binding to library classes ObeservableList, Long, Integer etc but now need to bind to values of custom class. I created TaskOutput class that includes StringProperty for binding purposes as follows: public class TaskOutput { private final StringProperty textValue = new SimpleStringProperty(); public TaskOutput(String textValue) { this.textValue.set