javafx-8

Insert only numbers in Spinner Control

这一生的挚爱 提交于 2019-11-29 07:15:18
I tested Spinner control in Java 8u40 import javafx.application.Application; import javafx.geometry.Insets; import javafx.scene.Scene; import javafx.scene.control.Label; import javafx.scene.control.Spinner; import javafx.scene.control.SpinnerValueFactory; import javafx.scene.layout.GridPane; import javafx.stage.Stage; public class MainApp extends Application { public static void main(String[] args) { Application.launch(args); } @Override public void start(Stage stage) { final Spinner spinner = new Spinner(); spinner.setValueFactory(new SpinnerValueFactory.IntegerSpinnerValueFactory(0, 10000));

JavaFX. Set different icons for the title bar and the operating system task bar

那年仲夏 提交于 2019-11-29 06:46:56
问题 Is there a way in JavaFX to set different application icons for the title bar and for the operating system task bar? The problem is that the icon shown in the system task bar is much bigger compare to the icon in the title bar and they cannot be re-sized properly by the system. I would like to use different images for the different icon sizes. Similar to what you do in an .ico file. If I call stage.getIcons().add(...) two times, the former image will be always used for both bars. I was also

How can I bypass the JavaFX's TableView “placeholder”?

馋奶兔 提交于 2019-11-29 06:42:29
JavaFX's TableView has a placeholder property that is basically a Node that gets displayed in the TableView whenever it is empty. If this property is set to null (its default value), it appears as a Label or some other text based Node that says "There is no content in the table." But if there are any rows of data in the table, then the placeholder Node disappears and the entire vertical space in the TableView gets filled with rows, including empty rows if there isn't enough data to fill the whole table. These empty rows are what I want, even when the table is empty . In other words, I don't

How to prevent TableView from doing TableColumn re-order in javaFX 8?

感情迁移 提交于 2019-11-29 06:39:54
I read this https://bugs.openjdk.java.net/browse/JDK-8102128 but I haven't found something in the Api of JavaFX 8.There isn't any way of prevent reordering in TableView? Alexander Chingarev Spent half of a day trying to solve the problem. Maybe my investigation can be useful for someone else. It's possible to disable column reordering using some hacks. And here're the steps: Get table header. This can be done as described here: https://stackoverflow.com/a/12465155 Add change event listener to reorderingProperty which sets reordering back to false. Full code is here: tableView.widthProperty()

ScrollPanes in JavaFX 8 always have gray background

谁都会走 提交于 2019-11-29 05:25:05
When I upgraded by JavaFX app from JavaFX 2 to JavaFX 8, I noticed that ScrollPanes always showed up as gray rectangles, even with a background color set or the background set to be transparent. I found the solution in this discussion: https://community.oracle.com/thread/3538169 First I needed this: .scroll-pane > .viewport { -fx-background-color: transparent; } Then I could set the background color to whatever I like. In this case, I'm making all ScrollPane backgrounds transparent: .scroll-pane { -fx-background-color: transparent; } Came acroos this just now, it's not working with -fx

How can I get the window handle (hWnd) for a Stage in JavaFX?

浪子不回头ぞ 提交于 2019-11-29 05:06:12
We're building a JavaFX application in Windows, and we want to be able to do some things to manipulate how our application appears in the Windows 7/8 taskbar. This requires modifying a Windows variable called the " Application User Model ID ". We've already managed to do exactly what we want in Swing by using JNA , and we'd like to repeat our solution in JavaFX. Unfortunately, to do this, we need to be able to retrieve the hWnd (window handle) for each window in our application. This can be done in Swing/AWT via the JNA Native.getWindowPointer() method, which works with java.awt.Window , but I

How do I add a value to items in a ComboBox in JavaFX

半世苍凉 提交于 2019-11-29 04:53:52
How can I add a value to items in a combo box so when the user selects an item from the ComboBox I am able to display the price for that item Eg. if the user selects an animal I can display the price of that animal. The the user selects dog then I can display the price of $45 . public class comboBox extends Application { Stage window; Scene scene; Button button; ComboBox<String> comboBox; public static void main(String[] args) { launch(args); } @Override public void start(Stage primaryStage) throws Exception { window = primaryStage; window.setTitle("ComboBox"); button = new Button("Submit");

Headless testing with JavaFx and TestFx

不想你离开。 提交于 2019-11-29 04:46:45
I have a simple JavaFx application (Java 8) that has a unit test using TestFx. However, when the test is run, the application window starts up and the mouse is moved to do whatever action is in my test. Can these tests be run in a way where the application doesn't popup and I can still use my mouse for other things as the automated build and tests are running? Update: I found this blog post that provides the solution for me to this problem. As the author suggests, you need to add the following dependency to your build: testRuntime 'org.testfx:openjfx-monocle:1.8.0_20' Then you will need to

JavaFx 8 - Scaling / zooming ScrollPane relative to mouse position

别等时光非礼了梦想. 提交于 2019-11-29 04:39:12
I need to zoom in / out on a scroll pane, relative to the mouse position. I currently achieve the zooming functionality by wrapping my content in a Group, and scaling the group itself. I create a new Scale object with a custom pivot. (Pivot is set to the mouse position) This works perfectly for where the Group's initial scale is 1.0, however scaling afterwards does not scale in the correct direction - I believe this is because the relative mouse position changes when the Group has been scaled. My code: @Override public void initialize(URL location, ResourceBundle resources) { Delta initial

Performance issue with JavaFX LineChart with 65000 data points

折月煮酒 提交于 2019-11-29 04:25:52
It takes JavaFX 15 minutes to build described LineChart which doesn't work for my task. Similar implementation using good old Swing and jFreeChart takes 1.5 seconds to build chart. But I would still like to implement a JavaFX one. Here is my code: public class FXMLController implements Initializable { @FXML private Label statusbar; @FXML public LineChart lineChart; @FXML public Button connect; @FXML public MenuItem options; @FXML public NumberAxis xAxis; @FXML NumberAxis yAxis; @FXML private void connect(ActionEvent event) { } public static FileChooser fileChooser = new FileChooser(); public