javafx-8

JavaFX: optimal width of TextFlow with word-wrap

无人久伴 提交于 2019-12-06 06:15:17
With Textflow.setMaxWidth(double) I can achieve text wrapping. But how can I adjust the width of TextFlow afterwards so that it is based on the actual wrapping position? In other words, how to let the TextFlow bounds snap to all of its children Text bounds to get rid of the empty space on the right: **Edit** I have made some progress on this issue. My class derived from TextFlow now contains: double maxChildWidth = 0; for (Node child : getManagedChildren()) { double childWidth = child.getLayoutBounds().getWidth(); maxChildWidth = Math.max(maxChildWidth, childWidth); } double insetWidth =

How to detect location and size of tab header in JavaFX

北慕城南 提交于 2019-12-06 06:05:59
I am still new to javaFX. In my code I need to get location and size of tab header, but I can't find any property or function which return its size or location. I don't understand your question properly, but generally you can use the lookup function to get the .tab-header-area CSS selector which is actually a StackPane . TabPane tabPane = new TabPane(); tabPane.getTabs().addAll(new Tab("Tab1"), new Tab("Tab2"), new Tab("Tab3")); Button b = new Button("Get header"); b.setOnAction((e) -> { StackPane headerArea = (StackPane) tabPane.lookup(".tab-header-area"); System.out.println("Coordinates

JavaFX TreeTableView leaves icons behind when collapsing

僤鯓⒐⒋嵵緔 提交于 2019-12-06 05:48:45
问题 I have a TreeTableView where every node has an icon. Everything works perfectly when I expand the tree, but when I collapse the tree, the icons of the no longer visible items are left behind. The rows and the text are removed, but the icons remain "free-floating". In the screenshot you can see the TreeTableView twice, once expanded with the correct text, and once collapsed with only the remaining icons. The screenshot above was created from the following minimal example (you just need to add

JavaFX Live Time and Date

对着背影说爱祢 提交于 2019-12-06 04:39:25
问题 I am building currently an application using JavaFx with an extra feature that displays the current date and time in the top corner of the scene. Since I am new to JavaFX, I don't know how to implement this one. I tried to use an old code in swing but I got an IllegalStateException Error. Here's my code. MainMenuController.java @FXML private Label time; private int minute; private int hour; private int second; @FXML public void initialize() { Thread clock = new Thread() { public void run() {

Display Math Formula in javaFX

梦想与她 提交于 2019-12-06 04:35:33
问题 I want to know how to display math formula in a label for exemple in JavaFX. Like this picture : I want the .jar of a library and a small example in JavaFX. I already found some libraries but they are only for Swing/AWT. I tried some of them, but they don't work for me. Displaying fancy equations with Java 回答1: Since JLaTeXMath is using the Graphics2D API for rendering, you can use FXGraphics2D to draw the output to a JavaFX Canvas . For sample code, please refer to my answer to another

JavaFX stage.setOnCloseRequest without function?

邮差的信 提交于 2019-12-06 04:18:38
This is my Start-Methode. First i create a stage and set a title and a scene. And i wanna create a dialog if someone wants to close the window on the window-close-btn [X]. i thought i will catch this event with the setOnCloseRequest()-function. But i still can close all stages i open while runtime. @Override public void start(final Stage primaryStage) throws Exception { primaryStage.setTitle("NetControl"); primaryStage.setScene( createScene(loadMainPane()) ); primaryStage.setOnCloseRequest(new EventHandler<WindowEvent>() { @Override public void handle(final WindowEvent event) { //Stage init

JavaFX TableColumns' headers not aligned with cells due to vertical scrollbar

╄→尐↘猪︶ㄣ 提交于 2019-12-06 04:14:29
问题 after having spent the last few hours searching the web for this issue I decided that I need your help. The issue is similar to this topic: Javafx: Tableview header is not aligned with rows No answer has been provided there and also, I think, my case is slightly different: I have a properly setup TableView with reused CellFactories and CellValueFactories. Data-wise, everything works 100% the way I intended. However once I populated my table with more rows than my view can show it naturally

how to use javafx textfield maxlength

浪尽此生 提交于 2019-12-06 03:52:18
问题 How use this code in my main class of javafx. So that I can set maxlength of characters in javafx texfield. class LimitedTextField extends TextField { private final int limit; public LimitedTextField(int limit) { this.limit = limit; } @Override public void replaceText(int start, int end, String text) { super.replaceText(start, end, text); verify(); } @Override public void replaceSelection(String text) { super.replaceSelection(text); verify(); } private void verify() { if (getText().length() >

How to style a SVG using CSS in javaFX FXML

让人想犯罪 __ 提交于 2019-12-06 03:05:47
问题 I'm using SVG for an image in a button. But I'm not able to fill in color for it through CSS. Below is the code to render a button. <Button onAction="#closeApplication" > <graphic> <SVGPath content="M10,16 10,0 0,8z" styleClass="button‐icon‐shape" /> </graphic> </Button> here is the css .button-icon-shape SVGPath{ -fx-fill: red; } 回答1: here is how it worked. I had to style the button and use the class to style the svg in the button. <Button onAction="#closeApplication" styleClass="closeButton

Detect When A Node is Visible in a Scene

折月煮酒 提交于 2019-12-06 01:34:00
问题 I am trying to find a way to detect (or receive notification) that a Node has been added to a Scene and is visible. I am creating Node objects off the main JavaFx thread and add them to the Stage and Scene using Platform.runLater() . However I would like the Node object to receive notification that is has been added to the Scene and is visible, for example I wish to trigger an animation to start. I can't seem to find any property or method to add a listener to capture such an event. Any