javafx

JavaFX Class controller Stage/Window reference

折月煮酒 提交于 2019-12-29 06:29:14
问题 Is there any way of getting the Stage/Window object of an FXML loaded file from the associated class controller? Particularly, I have a controller for a modal window and I need the Stage to close it. 回答1: I could not find an elegant solution to the problem. But I found these two alternatives: Getting the window reference from a Node in the Scene @FXML private Button closeButton ; public void handleCloseButton() { Scene scene = closeButton.getScene(); if (scene != null) { Window window = scene

How to wait for a transition to end in javafx 2.1?

狂风中的少年 提交于 2019-12-29 05:31:06
问题 My scene consists only of an ImageView, displaying an image. I would like to fade the image to black (assigned color of the scene), then after some time, fade from black to the image again. I found the FadeTransition very fitting for this purpose. This is a piece of my code: // fade to black transition FadeTransition ft1 = new FadeTransition(Duration.millis(2000), myImageView); ft1.setFromValue(1.0); ft1.setToValue(0.0); ft1.play(); // fade from black transition FadeTransition ft2 = new

ProGuard breaks JavaFX application

本秂侑毒 提交于 2019-12-29 05:17:05
问题 I'm trying to obfuscate my JavaFX application but it fails. The generated result does not work and I do not understand why. The resulting jar just fails because the fxml file cannot load all imports anymore (ClassNotFoundException). The Deployment workflow: Build runnable jar (in IntelliJ knwon as an artifact) Obfuscate that jar with ProGuard Fix some issues in that jar that ProGuard fails to do 1) The minimal example application The example application 'GuardTest' is a IntelliJ project that

Timeline to Display Random images one by one in a slideshow

别等时光非礼了梦想. 提交于 2019-12-29 02:02:26
问题 I want to display my images randomly one by one. The code below displays images one by one only if i put the duration time in seconds like: new KeyFrame(Duration.seconds(1), new KeyValue(imageView.imageProperty(), image1)), new KeyFrame(Duration.seconds(2), new KeyValue(imageView.imageProperty(), image2)), new KeyFrame(Duration.seconds(3), new KeyValue(imageView.imageProperty(), image3)), new KeyFrame(Duration.seconds(4), new KeyValue(imageView.imageProperty(), image4)), So, my code will

Can't build a gluon project for mobile using gradle

ⅰ亾dé卋堺 提交于 2019-12-29 01:39:06
问题 I followed the instructions on http://docs.gluonhq.com/charm/4.0.1/#_getting_started. I'm using eclipse 4.5.2 and JDK 1.8.0_102. I also downloaded Android Studio with the 24/25 API level SDK from https://developer.android.com/studio/index.html#Other. Here is what I did: downloaded gradle 3.1 and set up the environment variables so gradle -v returns the correct information. installed the eclipse gluon plugin version 2.4.0 from http://download.gluonhq.com/tools/eclipse/release installed

Is there a “fill” function for arbitrary shapes in javafx?

空扰寡人 提交于 2019-12-29 01:28:35
问题 I need to know in which way I can color the following image (PNG) by using JavaFX. This image is currently included in a ImageView of JavaFX: I want to color region 1 blue, the second one red, and the last two purple. How can I do this in JavaFX? Isn't there some kind of function as in Windows Paint? (You know, the painting bucket that fills a certain area with a color between borders). 回答1: Suggested Approach You can use a flood fill algorithm. Sample Code import javafx.application

Best practice to decorate an ObservableList and retain change events

不打扰是莪最后的温柔 提交于 2019-12-29 01:17:45
问题 My datasource provides an ObservableList<String> , however for my ListView I need an ObservableList<Warning> . A Warning is basically just a decorator for the strings, adding a boolean to provide a means for tracking the state of checkboxes my ListView, as proposed in this answer. class Warning { private final ReadOnlyStringWrapper name; private final BooleanProperty checked; /* ... */ } Currently I am observing change-events in the original list and add/remove items in the warnings list

Best practice to decorate an ObservableList and retain change events

筅森魡賤 提交于 2019-12-29 01:16:07
问题 My datasource provides an ObservableList<String> , however for my ListView I need an ObservableList<Warning> . A Warning is basically just a decorator for the strings, adding a boolean to provide a means for tracking the state of checkboxes my ListView, as proposed in this answer. class Warning { private final ReadOnlyStringWrapper name; private final BooleanProperty checked; /* ... */ } Currently I am observing change-events in the original list and add/remove items in the warnings list

How can I style a JavaFX menu and its items in CSS?

核能气质少年 提交于 2019-12-28 17:25:11
问题 I've got a MenuBar that is setup as follows in FXML: <MenuBar VBox.vgrow="NEVER"> <menus> <Menu mnemonicParsing="true" text="_File"> <items> <MenuItem mnemonicParsing="true" text="_New Project"/> <MenuItem mnemonicParsing="true" text="_Open…"/> <MenuItem mnemonicParsing="false" text="Quit"/> </items> </Menu> </menus> </MenuBar> This produces a menu as follows: I've successfully styled the MenuBar and the Menu File with the following CSS: .menu-bar { /* The menu bar itself */ } .menu { /* The

How to make a javafx button with circle shape of 3xp diameter?

a 夏天 提交于 2019-12-28 13:49:07
问题 I want to make a VERY small round button with no text on it. Here is how I tried. Button bt = new Button(); bt.setShape(new Circle(1.5)); bt.setMaxSize(3,3); However,there are two problems: 1.The shape of the button is not perfectly round, but more like an oval. 2. The bt.setMaxSize(1.5,1.5); does not take effect. As i reckon, its diameter is more than 3... How could I make a smaller rounder Button? Help Appreciated. 回答1: Update: on close review of the resultant button, setting the shape like