javafx-8

Should we use FXML in JavaFX custom controls or not?

跟風遠走 提交于 2019-12-05 03:45:18
It seems wired to ask this, I would think that using FXML to write our custom components is the obviously the right way to go. But as we can see from ControlsFX, JFXextras and even the book 'Mastering JavaFX8 controls do not use or mention the use of FXML in custom controls. Despite that, the official documentation to say to go on that route, and create JavaFX controls via FXML. What is the more correct way and why ? There are two kinds of custom controls in JavaFX: fx:root based custom controls : These custom controls are styleable (support CSS), but are not skinnable. If you're an

Loading custom font using JavaFX 8 and css

廉价感情. 提交于 2019-12-05 03:15:32
The Problem I'm creating a Super Mario themed css style sheet for my application, and I want to change the font of my buttons to a custom font called Press Start 2P, which is the pixelated font used in the NES Mario games. However, my application's not loading the font for some odd reason. CSS code: .text { -fx-font-family: "Press-Start-2P"; } .button { -fx-background-color: transparent; //-fx-text-fill: rgb(255, 255, 255); } @font-face { font-family: Press-Start-2P; src: url("PressStart2P.ttf"); } When I run the application, it gives me this message: Apr 25, 2015 8:22:32 AM com.sun.javafx.css

JavaFX : How to pass value from background thread to JavaFX UI thread with Task

回眸只為那壹抹淺笑 提交于 2019-12-05 02:58:12
问题 I have one worker task which continuously consumes web service and returns integer value. My Application consist of different (30) text boxes with associated radio button. When I click radio button, I want to display value from background task into Text field next to radio button. How I can Pass value from background thread to JAVAFX UI thread in this particular situation? I am new to JavaFX and used following way. Is this correct approach? @FXML private TabPane mainTabPane; Created Task in

JavaFX: printing a node across multiple pages

六眼飞鱼酱① 提交于 2019-12-05 02:34:20
问题 I tried to get in touch with the new printing API of JavaFX that was introduced in JDK 8. Consider the following test program: import javafx.application.Application; import javafx.print.PrinterJob; import javafx.scene.Node; import javafx.scene.Scene; import javafx.scene.control.Button; import javafx.scene.control.ToolBar; import javafx.scene.layout.BorderPane; import javafx.scene.paint.Color; import javafx.scene.shape.Rectangle; import javafx.stage.Stage; public class SimplePrintingTest

JavaFX KeyEvent propagation order

99封情书 提交于 2019-12-05 01:28:59
问题 I want to listen to some KeyEvent in my scene, say KeyCode.ESCAPE (close the scene when pressed). scene.addEventHandler(KeyEvent.ANY, event -> { if (event.isConsumed()) return; switch (event.getCode()) { case ESCAPE: stage.hide(); event.consume(); break; default: break; } }); Now, the nodes inside the scene could have listened to ESCAPE too. // .... someOtherNode.addEventHandler(KeyEvent.ANY, e -> { if (e.getCode() == KeyCode.ESCAPE) { // do stuff e.consume(); } }); // .... How do I make sure

Label text position

安稳与你 提交于 2019-12-05 01:14:27
I have a Label with an image and text final Label label = new Label(labelText); label.setTextAlignment(TextAlignment.CENTER); ImageView livePerformIcon = new ImageView(MainApp.class.getResource("/images/Folder-icon.png").toExternalForm()); label.setGraphic(livePerformIcon); I get this as a visual result: How I can change the text position? I want to set the text below the Image? label.setContentDisplay(ContentDisplay.TOP); Play with this to see the effect of the different alignment settings: import javafx.application.Application; import javafx.geometry.Insets; import javafx.geometry.Pos;

JavaFX button with svg

匆匆过客 提交于 2019-12-05 00:51:46
问题 I have this SVG: M421.985,229.833L217.847,25.981c-7.235-7.238-16.94-13.374-29.121-18.416C176.541,2.522,165.407,0,155.318,0H36.547 C26.648,0,18.083,3.619,10.85,10.848C3.617,18.081,0.002,26.646,0.002,36.545v118.771c0,10.088,2.519,21.219,7.564,33.404 s11.182,21.792,18.417,28.837L230.118,421.98c7.043,7.043,15.602,10.564,25.697,10.564c9.89,0,18.558-3.521,25.98-10.564 l140.186-140.47c7.043-7.046,10.561-15.604,10.561-25.693C432.542,245.919,429.024,237.258,421.985,229.833z M117.202,117.201 c-7.142,7

Build JavaFX 8 with Maven

旧街凉风 提交于 2019-12-04 23:39:41
问题 I tested to create JavaFX 8 project with Netbeans 7.4. But unfortunately with no luck. This is the POM file: <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.dx57dc</groupId> <artifactId>JFX8M</artifactId> <version>1.0</version> <packaging>jar</packaging

JavaFX 8 DatePicker features

笑着哭i 提交于 2019-12-04 22:51:09
问题 I just start using the new JavaFX 8 control DatePicker . In DatePicker User Experience Documentation, it is stated that it has couple of cool features that I would like to have in my GUI application: I want to change the format from mm/dd/yyyy to dd/mm/yyyy . I would like to restrict the date that can be selected. The user can only select from today until the same day of next year. Display Hijri dates besides the original ones: How to implement these features? The JavaDoc doesn't say much

JavaFX: Tested/confirmed hardware (GPU) acceleration on Linux

∥☆過路亽.° 提交于 2019-12-04 21:22:06
I would like to know if anyone managed to get a working version of JavaFX 2.2 or 8 on Linux with hardware acceleration. Oracle provides a list of compatible GPUs: http://www.oracle.com/technetwork/java/javafx/downloads/supportedconfigurations-1506746.html But last time I've tried with a modern nVIDIA card and Ubuntu it reverted to software rendering. Ubuntu 12.04 and nVidia GTX 750 Ti (Official drivers): www@www-MS-7577:~$ java -Dprism.verbose=true -jar JavaFXApp.jar Prism pipeline init order: es2 sw Using platform text rasterizer Using java-based Pisces rasterizer Using dirty region