javafx-8

Wait for Platform.RunLater in a unit test

眉间皱痕 提交于 2019-12-30 10:13:08
问题 I have a presentation class storing an XYChart.Series object and updating it by observing the model. The Series updating is done by using Platform.runLater(...) I want to unit-test this, making sure the commands in runLater are performed correctly. How do I tell the unit-test to wait for the runLater commands to be done? Right now all I do is Thread.Sleep(...) on the test-thread to give the FXApplicationThread the time to complete, but that sounds stupid. 回答1: The way I solved it is as

JavaFX Button with multiple text lines

梦想与她 提交于 2019-12-30 09:58:14
问题 I need to create a toolbar in my screen that will have multiple buttons, and each button must have multiple lines of Text. For example: I looked over the internet and StackOverflow but I couldn't find anything showing how to do this in JavaFX. I'm using JavaFX 8. Someone could help me, please? Tks 回答1: Also you can use the wrapTextProperty . But you have to set toolbar height greater than expected button height. Button btn = new Button(); btn.wrapTextProperty().setValue(true); // or btn

JavaFX 8 - Add a graphic to a TitledPane on the right side

最后都变了- 提交于 2019-12-30 09:55:29
问题 I want to add a little icon to the title of a TitledPane . Therefore I set an empty title and add a HBox containing a Label and a ImageView as graphic. In this way the icon is shown close to the end of the text. I want it to be shown always next to the right border of the TitledPane . How can I do this? I also tried to use a BorderPane and add the Label to the center and the ImageView to the right, but the BorderPane doesn't get the maximum size of the TitledPane. So I tried to set MaxWidth

JavaFX 8 - Add a graphic to a TitledPane on the right side

风流意气都作罢 提交于 2019-12-30 09:55:11
问题 I want to add a little icon to the title of a TitledPane . Therefore I set an empty title and add a HBox containing a Label and a ImageView as graphic. In this way the icon is shown close to the end of the text. I want it to be shown always next to the right border of the TitledPane . How can I do this? I also tried to use a BorderPane and add the Label to the center and the ImageView to the right, but the BorderPane doesn't get the maximum size of the TitledPane. So I tried to set MaxWidth

Selecting a period or a date using ONE JavaFX 8 DatePicker

邮差的信 提交于 2019-12-30 09:41:26
问题 On the application I am currently working, it is necessary to select a single date or a period from the same JavaFX 8 DatePicker. The preferred way of doing this would be as follows: Selecting a single date - same as default behaviour of the DatePicker. Selecting a period - select start/end date by holding down the mouse button and drag to the desired end/start date. When the mouse button is released you have defined your period. The fact that you cannot select dates other than those

How to center the content of a javafx 8 scrollpane

笑着哭i 提交于 2019-12-30 06:42:13
问题 I have a ScrollPane, which contains a GridPane, which contains an ImageView, which contains an Image. What I want is for the Image to be centered in the GridPane. Without the ScrollPane I was able to accomplish this with setAlignment(Pos.TOP_CENTER), however once I added the GridPane to the ScrollPane the Image was displayed in the upper-left corner. How do I either get the ScrollPane to use the setAlignment() value or manually center the Image? ---example edit--- code without scrollpane:

How to center the content of a javafx 8 scrollpane

和自甴很熟 提交于 2019-12-30 06:41:13
问题 I have a ScrollPane, which contains a GridPane, which contains an ImageView, which contains an Image. What I want is for the Image to be centered in the GridPane. Without the ScrollPane I was able to accomplish this with setAlignment(Pos.TOP_CENTER), however once I added the GridPane to the ScrollPane the Image was displayed in the upper-left corner. How do I either get the ScrollPane to use the setAlignment() value or manually center the Image? ---example edit--- code without scrollpane:

How to access the Scrollbars of a ScrollPane

狂风中的少年 提交于 2019-12-30 03:29:04
问题 I'm trying to get some information about the ScrollBar components that are by standard included in a ScrollPane . Especially i'm interested in reading the height of the horizontal Scrollbar . How can i reference it? 回答1: Since the mentioned methods did not work for everybody (including me), I investigated it a bit more and found the source of the problem. In general, both methods work, but only as soon as the ScrollPane's skin property has been set. In my case, skin was still null after

JavaFx 8: open a link in a browser without reference to Application

喜欢而已 提交于 2019-12-30 03:07:23
问题 Have got a Hyperlink. When clicked I want a link to be opened in an external browser. The usual method cited on the web seems to be: final Hyperlink hyperlink = new Hyperlink("http://www.google.com"); hyperlink.setOnAction(t -> { application.getHostServices().showDocument(hyperlink.getText()); }); However I don't have a reference to Application . The link is opened from Dialog, which is opened from a Controller, which is opened via an fxml file, so getting a reference to the Application

Javafx combobox styling

烈酒焚心 提交于 2019-12-30 01:24:07
问题 I need a combobox in javaFX whose popup behavior can be controlled, like upon clicking the combobox, instead of default behavior where it shows a drop down, i want the drop down to be shown above the combobox (insetad of display below the combobox) . Is it possible ? Can we do this with css ? Thanks for any help. 回答1: I hope this will work for you. Make some changes according your need .combo-box .list-cell { -fx-background: white; -fx-background-color: transparent; -fx-text-fill: -fx-text