javafx-8

JavaFX 8 - How to bind TextField text property to TableView integer property

♀尐吖头ヾ 提交于 2019-12-05 12:52:28
问题 Let's say I have a situation like this: I have a TableView (tableAuthors) with two TableColumns (Id and Name). This is the AuthorProps POJO which is used by TableView : import javafx.beans.property.SimpleIntegerProperty; import javafx.beans.property.SimpleStringProperty; public class AuthorProps { private final SimpleIntegerProperty authorsId; private final SimpleStringProperty authorsName; public AuthorProps(int authorsId, String authorsName) { this.authorsId = new SimpleIntegerProperty

expand TreeView (parent)nodes which contains selected item

跟風遠走 提交于 2019-12-05 12:49:13
I have a TreeView existing out of User objects. The TreeView represents the hierarchy of the Users: Master1 Super1 Super2 User1 User2 Super3 User3 Super4 Master2 ... Every TreeItem is Collapsed when the TreeView is initialized. However, it can be that when the FXML is loaded, a TreeItem object is passed through from another FXML file. Eg: User3 has been passed through: selectedUserTreeItem = (TreeItem<User>) currentNavigation.getPassthroughObject(); //this is the User3 TreeItem I try to use a recursive function to expand all the parent nodes from the selecterUserTreeItem if

JavaFX: two bound properties for Task

ε祈祈猫儿з 提交于 2019-12-05 12:33:00
I have a JavaFX 8 application and want to allow a Task to modify two different UI elements. As I understand it, if I had a single Label to modify, I could bind to the Label with mylabel.textProperty().bind(mytask.messageProperty()) and use updateMessage() in the Task. How can I do this with two different arbitrary types? I've looked at the examples in the concurrency and JavaFX docs but to me they do not explain this well. I understand a Task inherently has Message(String), Progress(double/long), Title(String), and Value(user defined) properties, but what if I want two or more arbitrarily

Insert text at the center of a image

≯℡__Kan透↙ 提交于 2019-12-05 11:55:54
I have this code which inserts Image into the center of a borderpane: private static final ImageView iv; static { iv = new ImageView(StartPanel.class.getResource("/com/dx57dc/images/6.jpg").toExternalForm()); } bpi.setCenter(iv); And now I have this problem. I have this insert text as a label at the center of the image. Text inftx = new Text("Infrastructure"); How I can do this? You can use a StackPane to performed the desired image overlap. The following code can be used on your example: private static final ImageView iv; static { iv = new ImageView(StartPanel.class.getResource("/com/dx57dc

JavaFX CSS class for GridPane, VBox, VBox

て烟熏妆下的殇ゞ 提交于 2019-12-05 11:52:48
Is there a predefined CSS class for JavaFX GridPane, VBox, HBox? I can't find anything in the CSS reference , but it seems weird that default components would not have one defined. If there isn't a pre-defined class, is there a better way than to add the class manually on all grids: GridPane pane = new GridPane(); pane.getStyleClass().add("grid-pane"); No, only Control subclasses have default css classes defined. I think this is because applications that want to manage their own graphics (using a Canvas or unmanaged Shapes, for example) probably will not use css, but will likely still use

How to render 3D text in JavaFX?

陌路散爱 提交于 2019-12-05 11:43:20
I'm making my first JavaFX project and I need to render some 3D text. I already put a PerspectiveCamera and I display a text node but it has a Z-dimension of 0 and I don't know how to change this. Thanks in advance! Have a look at the FXyz project. It already contains a Text3DMesh class that will allow you generating a 3D mesh for any string and font you need. Under the hood there is a complex process of converting (2D) Text to Path, Delaunay triangulation and mesh extrusion. As a result, you have a 3D mesh that can be easily rendered and textured (solid color, density map, images). Have a

Datepicker in JavaFX 8

陌路散爱 提交于 2019-12-05 10:49:14
Is there any implementation of Date Picker and Time Picker into the default JavaFX 8 package that I can use without using third party solutions? DatePicker Yes, Java 8 has a DatePicker : import javafx.application.Application; import javafx.scene.Scene; import javafx.scene.control.DatePicker; import javafx.stage.Stage; import java.time.LocalDate; public class PickerDemo extends Application { @Override public void start(Stage stage) { final DatePicker datePicker = new DatePicker(LocalDate.now()); datePicker.setOnAction(event -> { LocalDate date = datePicker.getValue(); System.out.println(

Wrapping Label text in a VBox using FXML

戏子无情 提交于 2019-12-05 10:39:09
I'm writing a JavaFX application and I'd like to create a screen that contains 2 long pieces of text. I don't know what the text is ahead of time, it will be filled in by some code at run time. To do this I thought I'd make a VBox with 2 Labels. I assume that if I don't add dimensions, the Labels will span the VBox. Since the text is long I'd like it to wrap. Here's the FXML that I tried: <VBox spacing="20" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1"> <children> <Label fx:id="label1" text="Dummy Text" wrapText="true" /> <Label fx:id="label2" text="Dummy Text"

Why SortedList.add() throws UnsupportedOperationException?

淺唱寂寞╮ 提交于 2019-12-05 10:24:01
Very simple code: import javafx.collections.FXCollections; import javafx.collections.ObservableList; import javafx.collections.transformation.SortedList; public final class SortedListTest { public static void main( String[] args ) { final ObservableList<Integer> il = FXCollections.observableArrayList(); final SortedList<Integer> sil = new SortedList<>( il ); sil.comparatorProperty().set((l,r)-> l-r ); sil.add( 12 ); } } Execution: Exception in thread "main" java.lang.UnsupportedOperationException at java.util.AbstractList.add(AbstractList.java:148) at java.util.AbstractList.add(AbstractList

Set image on left side of dialog

有些话、适合烂在心里 提交于 2019-12-05 10:10:20
I created this very simple example for JavaFX alert dialog for JavaFX8u40. public class MainApp extends Application { public static void main(String[] args) { Application.launch(args); } private Stage stage; @Override public void start(Stage primaryStage) throws Exception { Button create = new Button("Create Alert"); create.setTooltip(new Tooltip("Create an Alert Dialog")); create.setOnAction(e -> { createAlert(); }); primaryStage.setScene(new Scene(create)); primaryStage.show(); stage = primaryStage; } protected Alert createAlert() { Alert alert = new Alert(AlertType.WARNING); Image image1 =