javafx

JavaFX : Use a Thread more than once

二次信任 提交于 2020-01-01 08:40:10
问题 I'm new with JavaFX and I've a little problem with a thread: I can execute it twice and I can't find why. Here is a sum-upt of my code: Task<Void> task = new Task<Void>() { @Override public Void call() throws ImageLoadedException, HomographyException, IOException { try{ System.out.println("GO !"); return null; } catch (Exception e){ e.printStackTrace(); } return null; } @Override protected void succeeded() { super.succeeded(); System.out.println("SUCCEEDED"); } }; @FXML protected void launch

How do I get the close event of a stage in JavaFX?

落爺英雄遲暮 提交于 2020-01-01 08:02:37
问题 In JavaFX, how can I get the event if a user clicks the Close Button(X) (right most top cross) a stage? I want my application to print a debug message when the window is closed. ( System.out.println("Application Close by click to Close Button(X)") ) @Override public void start(Stage primaryStage) { StackPane root = new StackPane(); root.getChildren().add(btn); Scene scene = new Scene(root, 300, 250); primaryStage.setTitle("Hello World!"); primaryStage.setScene(scene); primaryStage.show(); //

Javafx: Detect ALL changes made to tableView including addition/deletion of table rows and cell edits on any table rows

安稳与你 提交于 2020-01-01 07:30:08
问题 Given that I have a tableView , how can I track all the changes, i.e. a new row is added / deleted, one of the table cells has its value changed , and fire off the same event when any of these changes are detected ? At the moment, I have the following code below, which only manages to detect change if I add in a row. It is not able to detect changes when I edit a table cell of any row and when I delete a row. ObservableList<Trade> observableListOfTrades =FXCollections.observableArrayList();

Java FX table column sorting with Comparator does not work

有些话、适合烂在心里 提交于 2020-01-01 07:07:25
问题 In Java FX I would like to display this Model in a sorted TableView: public class ProfilZuordnungTableRowModel { private int id; private double kundenwert; private String kundenwertFormatted; private BooleanProperty selected; } I would like to integrate a table column sorting with the column "Kundenwert". The displayed value should be the attribute "kundenwertFormatted" (String) and for sorting the attribute "kundenwert" (Double) should be used. So I wrote a comparator: class

Make a label update while dragging a slider

女生的网名这么多〃 提交于 2020-01-01 06:12:03
问题 I'm using a Slider in my javaFX project and I have a Label that updates when I move the slider. I want the Label to update whilst I'm dragging the Slider and not only when the drag is dropped. This is my code: betSlider.valueChangingProperty().addListener(new ChangeListener<Boolean>() { @Override public void changed(ObservableValue<? extends Boolean> source, Boolean oldValue, Boolean newValue) { betLabel.textProperty().setValue(String.valueOf((int)betSlider.getValue())); } }); 回答1: You just

How to detect keys

孤街醉人 提交于 2020-01-01 06:11:35
问题 I want to create table in which I want to configure hot key shortcuts. I have this simple table: public static final String Column1MapKey = "A"; public static final String Column2MapKey = "B"; private ObservableList<Map> generateDataInMap() { int max = 110; ObservableList<Map> allData = FXCollections.observableArrayList(); for (int i = 1; i < max; i++) { Map<String, String> dataRow = new HashMap<>(); String value1 = "A" + i; String value2 = "B" + i; dataRow.put(Column1MapKey, value1); dataRow

How to detect keys

微笑、不失礼 提交于 2020-01-01 06:11:11
问题 I want to create table in which I want to configure hot key shortcuts. I have this simple table: public static final String Column1MapKey = "A"; public static final String Column2MapKey = "B"; private ObservableList<Map> generateDataInMap() { int max = 110; ObservableList<Map> allData = FXCollections.observableArrayList(); for (int i = 1; i < max; i++) { Map<String, String> dataRow = new HashMap<>(); String value1 = "A" + i; String value2 = "B" + i; dataRow.put(Column1MapKey, value1); dataRow

Make a label update while dragging a slider

放肆的年华 提交于 2020-01-01 06:10:43
问题 I'm using a Slider in my javaFX project and I have a Label that updates when I move the slider. I want the Label to update whilst I'm dragging the Slider and not only when the drag is dropped. This is my code: betSlider.valueChangingProperty().addListener(new ChangeListener<Boolean>() { @Override public void changed(ObservableValue<? extends Boolean> source, Boolean oldValue, Boolean newValue) { betLabel.textProperty().setValue(String.valueOf((int)betSlider.getValue())); } }); 回答1: You just

JavaFX: create a vertical menu ribbon

天涯浪子 提交于 2020-01-01 05:52:27
问题 An example of what I am trying to accomplish here is: when you open an office Word 2013 file and you click file, in the left side it shows a list {Info, New, Open...}. Are there any JavaFX components like that? I am looking for a kind of List of (something) whose items are aligned vertically and you can click on to do something (in my case change the view on the right exactly like Word). 回答1: You can easily reproduce the Word like menu with a VBox and buttons with custom CSS styles. Here is a

SceneBuilder 2: Do controller classes need to necessarily be in the same folder as the view FXML files?

萝らか妹 提交于 2020-01-01 05:49:29
问题 I'm loving JavaFX and SceneBuilder, but I just can't figure out how to make SceneBuilder link my FXML views with their Java controllers when they are not in the same folder. I'd just like to have this folder structure: package |-- model |-- view | |--someElementView.fxml | \--anotherElementView.fxml \-- control |--someElementController.java \--anotherElementController.java Instead I can only make SceneBuilder recognise my controllers if I have this folder structure which I'd like to avoid: