javafx-8

JavaFx: How to validate mutilple TextFields creating at run time?

被刻印的时光 ゝ 提交于 2019-12-11 05:54:28
问题 I am creating multiple TextFields at run time using for-loop and adding them to inside Gridpane(which has 8 columns) like this: public static GridPane table(int rows){ GridPane table = new GridPane(); for(int i=0; i<rows; i++){ JFXTextField textField1 = new JFXTextField(); textField1.setAlignment(Pos.CENTER); JFXTextField textField2 = new JFXTextField(); textField1.setAlignment(Pos.CENTER); JFXTextField textField3 = new JFXTextField(); textField1.setAlignment(Pos.CENTER); JFXTextField

AnchorPane Constraints in percentages

ⅰ亾dé卋堺 提交于 2019-12-11 04:46:04
问题 I am working on a project and I need you help. I want to know that is this possible to set anchorpane constraints in percentage as something like AnchorPane.setLeftAnchor(content1, 35%); 回答1: Yes it can be by updating constraint values on every scene size change: public class AnchorDemo extends Application { private final Button button = new Button("Add"); private final ListView list = new ListView(); @Override public void start(Stage primaryStage) { AnchorPane root = new AnchorPane();

Javafx : SplitPane resize children

旧时模样 提交于 2019-12-11 04:42:23
问题 I fave an .fxml file, in which I have added some TitledPane but I cannot resize them in the application. Here is the code: <ScrollPane AnchorPane.topAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0"> <SplitPane orientation="VERTICAL" fx:id="splitPane"> <TitledPane> <TextArea fx:id="taTop" wrapText="true" editable="false" prefHeight="100"/> </TitledPane> <TitledPane> <TableView fx:id="tableFrist" minHeight="120" maxHeight="120"> <columns>

rotate javafx image view around custom point

天大地大妈咪最大 提交于 2019-12-11 04:36:44
问题 I am starting to learn JavaFX now when I try to rotate the image view using imgv.setRotate(angle); it rotates around its central axis but when I try to rotate it around a custom point inside the image using imgv.getTransforms().add(new Rotate(Angle,custom_x,custom_y); it rotates randomly and I can't figure its axis of the rotation this was the same as imgv.getTransforms().add(new Rotate(Angle,custom_x,custom_y,1.0,Rotate.Z_AXIS); is there any way to rotate the image around a custom point here

Fxml Controller Inject Final Field

╄→尐↘猪︶ㄣ 提交于 2019-12-11 04:32:12
问题 For a fxml controller class that would map to an fxml control, such as: public MyController { @FXML private Button button; } Is it possible to declare the button field as final? If it was done, the java compiler (javac) would flag an error about that field not being initialized. It is understood that the button field will be eventually initialized using the @FXML injection. Albeit, javac does not fully understand this, or even how it would be done. Although the final qualifier may not be

How to assign a shortcut (key combination) to a JavaFx dialog

非 Y 不嫁゛ 提交于 2019-12-11 04:28:29
问题 I have not found a direct way to assign a keyboard shortcut to a button type in a JavaFx 8 dialog. For instance: dialog.dialogPane().getButtonTypes.addAll(ButtonType.OK, ButtonType.Cancel) How can I assign the ESC key to ButtonType.Cancel ? Thanks. 回答1: You can use an accelerator as demonstrated in: Using JavaFX 2.2 Mnemonic (and accelerators) JavaFX dialogs are a bit weird (and complicated) in the way they define and use buttons, so adding the accelerator gets a little convoluted, but is

Javafx 8 drawing a line between translated nodes

折月煮酒 提交于 2019-12-11 04:24:14
问题 How do you draw a line between the centers of translated nodes? Given for example the following code snippet: public class Test extends Application{ @Override public void start(Stage primaryStage) { StackPane root = new StackPane(); Circle circle1=new Circle(10, Color.GREEN); root.getChildren().add(circle1); Circle circle2=new Circle(10, Color.RED); root.getChildren().add(circle2); Scene scene = new Scene(root, 300, 250); primaryStage.setScene(scene); primaryStage.show(); circle1

JavaFX, How do I trigger an event if someone check a CheckBox in Tableview

荒凉一梦 提交于 2019-12-11 04:23:00
问题 i hava a big problem in JavaFX. I created a TableView an i added some CheckBoxes to the TableView. I want to trigger an event if someone check the Checkbox in the TableView. I tried some different ways but I always have the same problem. I start the program and the "CheckBox trigger event" runs five times before showing the GUI. After that I can click on the Checkboxes but nothing happened. This is my code and I hope u can help me. Thx! Controller.class package GUI; import java.io.IOException

How to get the absolute rotation of a Node in JavaFX

限于喜欢 提交于 2019-12-11 04:16:20
问题 In JavaFX the rotateProperty of a Node provides me with its rotation in degree relative to its parent. Is there a way to get the absolute rotation in degree, either relative to the Scene or the Screen? For example, is there a way to calculate the angle from the Transform object of a Node i can get from getLocalToSceneTransform()? 回答1: So, i did the math myself, and for my case i either get the rotation in Radians via: double xx = myNode.getLocalToSceneTransform().getMxx(); double xy = myNode

Set Items Selected in a CheckComboBox

僤鯓⒐⒋嵵緔 提交于 2019-12-11 04:03:37
问题 I´m using the CheckComboBox by ControlsFX for a Project and I want to set some of the Items Checked from the Start so I tried this Code in my initialize-Methode, but when i start the program, nothing is set Selected/Checked. checkBox.getCheckedModel.check(1); I´m using an ObservableList of Strings for the Box and got it build into my FXML file and everything works fine, but the CheckModel-thing refuses to work. Thanks in advance! 回答1: Hi you can try use the folllowing CheckComboBox