javafx-8

How to properly use JavaFX TableView and ObservableList classes?

我的梦境 提交于 2020-01-06 12:57:20
问题 I got a class where I receive some collection structure: public class YIFY { private static List<Pelicula> resultados; public static void setResultados(List<Pelicula> resultados) { YIFY.resultados = resultados; } } Later, at another class I associate the contents of such List to a TableView . However I create an FXCollections.observableArrayList() which is set as the bind element to the table. This is how I do it: peliculas = FXCollections.observableArrayList(YIFY.getResultados());

JavaFX java.lang.IllegalStateException (Stage)

只愿长相守 提交于 2020-01-06 09:07:10
问题 I am having some problem here. This is my code for the first screen: myps.initStyle(StageStyle.UNDECORATED); // I am trying to create a splash screen look a like Now I am trying to get my borders and titles all back so I do something like this: // Exiting splash screen myps.hide(); myps.initStyle(StageStyle.DECORATED); // (Problem line) With the thoughts of hide() is going to set my stage visibility to invisible, but the problem line gives me this error: Cannot set style once stage has been

JavaFX CustomMenuItem strange behaviour with TextField

拜拜、爱过 提交于 2020-01-06 06:52:54
问题 maybe someone can explain the following behaviour - and hopefully, possible workarounds... thanks. When using a CustomMenuItem containing a TextField, the action of the MenuItem above gets triggered by pressing enter inside the textfield... unless the textfield has an actionlistener set (not added)... I need to use addEventHandler, not setOnAction... :-/ import javafx.application.Application; import javafx.scene.Scene; import javafx.scene.control.CustomMenuItem; import javafx.scene.control

Is there a way to update a scrollbar when there is a modification which changes its scrollpane content height. It is during a dragging operation

霸气de小男生 提交于 2020-01-06 06:25:07
问题 There is a JAVAFX Scrollpane which contains a treeview. Inside the treeview, i have a few vboxs. Their height can change. Firstly, there was a problem : when i move a vbox thanks to a drag operation, the scrollbar which belongs to the scrollpane didn't want to move. In order to resolve this problem, i have done a few researches here. I found a solution. The code is below private ScrollBar getVerticalScrollbar() { ScrollBar result = null; for (Node n : scrollPane.lookupAll(".scroll-bar")) { if

How to orient the muzzle of a gun ? [JavaFX]

夙愿已清 提交于 2020-01-06 05:36:09
问题 I am creating a game in which you use guns and play against the computer/someone else. You can orient that gun with a slider. But I don't manage to orient the muzzle of the gun. I tried in different ways, nothing worked as expected. I googled a bit but I found nothing that worked and nothing that seems to have a chance of working. So I ask you, what haven't I tried yet ? What should I do different ? Here is a picture explaining what I said : Expectations Here is the concerned code : package

JavaFx element not binding to controller variable on fx:id [duplicate]

不羁的心 提交于 2020-01-06 03:37:26
问题 This question already has answers here : JavaFX FXML controller - constructor vs initialize method (3 answers) Closed 3 years ago . This is likely pilot error, but the FXML attribute is not binding to the controller class on fx:id. I've whittled it down to a trivial example, but still "no joy". What am I overlooking? FXML file... <?xml version="1.0" encoding="UTF-8"?> <?import javafx.scene.layout.AnchorPane?> <?import javafx.scene.layout.BorderPane?> <BorderPane fx:id="mainFrame" maxHeight="

JavaFX Change text under Progress Indicator (default: Done)

房东的猫 提交于 2020-01-05 08:02:09
问题 how can I change default text "Done" under ProgressIndicator in JavaFX? 回答1: This is a little bit tricky but it is possible: In JavaFX 2.2 this is made like this: ProgressIndicator indicator = new ProgressIndicator(); ProgressIndicatorSkin indicatorSkin = new ProgressIndicatorSkin(indicator); final Text text = (Text) indicatorSkin.lookup(".percentage"); indicator.progressProperty().addListener(new ChangeListener<Number>() { @Override public void changed(ObservableValue<? extends Number> ov,

How to cancel selection in ListView?

有些话、适合烂在心里 提交于 2020-01-05 07:33:52
问题 I try to cancel user selection in a ListView according a condition. I tried to consume mouse clicked and mouse pressed event in ListView and ListCell but it didn't work. I don't understand why bu events occur after the selected item property change. How can I cancel the user selection? 回答1: If I understand correctly, you want to prevent users from selecting items by clicking on it. I further suppose that you tried a solution like this: listView.addEventHandler(MOUSE_CLICKED, click -> click

How to cancel selection in ListView?

你说的曾经没有我的故事 提交于 2020-01-05 07:32:27
问题 I try to cancel user selection in a ListView according a condition. I tried to consume mouse clicked and mouse pressed event in ListView and ListCell but it didn't work. I don't understand why bu events occur after the selected item property change. How can I cancel the user selection? 回答1: If I understand correctly, you want to prevent users from selecting items by clicking on it. I further suppose that you tried a solution like this: listView.addEventHandler(MOUSE_CLICKED, click -> click

JavaFX Slider: Track length? Tick Label Color?

若如初见. 提交于 2020-01-05 07:03:54
问题 .slider .track { -fx-pref-width: 300px; } .slider .axis-tick-label { -fx-text-fill: white; } My feeble attempts of writing CSS styles for the slider both don't work. I'm 100% sure my syntax is off. Any help? 回答1: You can do it by setting the -fx-pref-width attribute of slider and setting the -fx-tick-label-fill attribute of .slider .axis : .slider { -fx-pref-width: 300px; } .slider .axis { -fx-tick-label-fill: white; } Note: For vertical Slider , to affect the length of the track, you have to