fxml

getHostServices().showDocument() in a FXML File

試著忘記壹切 提交于 2019-11-28 14:27:33
Is there any easy way to put into the toHomepage() method the getHostServices().showDocument() command somehow, instead of doing lines and lines of code, so the code should look clean and simple? package sample; import javafx.application.HostServices; import javafx.event.ActionEvent; import javafx.fxml.FXML; import javafx.scene.control.Button; public class Controller { @FXML private Button facebookButton; @FXML void toHomepage(ActionEvent event) { } } If I press the button, it should directly link me to the Facebook URL You need to pass the HostServices to the Controller . Key Code: Set the

Show / Hide a Node within a stage

喜欢而已 提交于 2019-11-28 13:09:16
I am aware that there are already answers for this question but somehow, it was not able to solve my problem. When I click the textfield in IMAGE1, I want the keyboard FXML(IMAGE2) to appear as is in IMAGE3. But the thing is, I can't seem to find the solution. How do I do this? I need your help please. IMAGE1 IMAGE2 IMAGE3 I am experimenting with something similar, here is what I came up with (one of many possible solutions): You need to wrap your main layout (IMAGE1) in a StackPane . Its usage is to overlay what needs be overlaid (the keyboard in your case). The keyboard is placed in another

Creating dynamic amount of components in FXML

我只是一个虾纸丫 提交于 2019-11-28 12:57:33
问题 I made a note card program that can help you study with JavaFX. It saves the class through XML and on boot up, it finds the XML files and adds them to an ArrayList called allProjects of type NoteCardSet, an ArrayList of NoteCards. With this, I made a dynamic amount of buttons that puts them 4 columns wide. Here is the code for that: int amountPerRow = 4; int current = 0; int row = 0; for (NoteCardSet noteCardSet : allProjects) { Button b = new Button(noteCardSet.getName()); GridPane

Redirect Console Output to JavaFX TextArea?

江枫思渺然 提交于 2019-11-28 12:49:05
I want to show the console output in a JavaFX TextArea... unfortunately I cannot find any working example for JavaFX but only for Java Swing, which not seems to work in my case. EDIT: I tried to follow this example: http://unserializableone.blogspot.ch/2009/01/redirecting-systemout-and-systemerr-to.html and extended my code as shown below. However, there is no console output anymore in my Eclipse IDE but also no output in my TextArea. Any idea where I am doing wrong? public class Activity extends OutputStream implements Initializable { @FXML public static TextArea taRecentActivity; public

Populate Choicebox defined in FXML

血红的双手。 提交于 2019-11-28 12:40:38
I'm learning javaFX and my problem is that I have simple window with some choicebox and button. This window is defined via FXML which is also associated with controller class. I would like to know, how to populate this choicebox with data in the controller class, because using @FXML reference to this choicebox throws NullpointerEception EDIT - added source code FXML code <AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="240.0" prefWidth="320.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller=

Java FX changing value of Label from different scene

时间秒杀一切 提交于 2019-11-28 12:08:58
问题 I have two scenes. The first scene invokes second scene using the following code. @FXML private void confirmation(ActionEvent event) throws IOException{ Stage confirmation_stage; Parent confirmation; confirmation_stage=new Stage(); confirmation=FXMLLoader.load(getClass().getResource("Confirmation.fxml")); confirmation_stage.setScene(new Scene(confirmation)); confirmation_stage.initOwner(generate_button.getScene().getWindow()); confirmation_stage.show(); } There is a label in "Confirmation

How to Update a TreeView in JavaFX with data from users

独自空忆成欢 提交于 2019-11-28 11:54:32
问题 I am begging with JavaFx, and I realized that I need some help to update a TreeView with some TreeItems in runtime, and it should be updated in the main window. Here, you can see a screenshot of the two windows: The bigger is the main window and it calls (by clicking in File >> New Project), new smaller. In the smaller window, I could get the String that is typed and than the enter button is clicked. The trouble is: How can I show the new items created by the "new project window" (the smaller

JavaFX How to set max/min window size?

♀尐吖头ヾ 提交于 2019-11-28 11:17:20
Does setMinSize() work on containers, GridPane for example? I have found that in my programm GridPane ignores min. size properties while resized manually. Here is the FXML code: <GridPane fx:id="gp" prefHeight="134.0" prefWidth="238.0" xmlns:fx="http://javafx.com/fxml" fx:controller="javafxapplication12.SampleController"> <columnConstraints> <ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" /> <ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" /> </columnConstraints> <rowConstraints> <RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" /

How can I show an image using the ImageView component in javafx and fxml?

拜拜、爱过 提交于 2019-11-28 10:05:10
I suppose it's a very simple thing but I just can't get behind it. All I want is to show an image over an ImageView linked to fxml. Here is my code: package application; import java.io.File; import javafx.application.Application; import javafx.stage.Stage; import javafx.scene.Scene; import javafx.scene.image.Image; import javafx.scene.image.ImageView; import javafx.scene.layout.AnchorPane; import javafx.fxml.FXML; import javafx.fxml.FXMLLoader; public class Main extends Application { @FXML private ImageView imageView; @Override public void start(Stage primaryStage) { try { AnchorPane root =

JavaFX FXML API version warning

落爺英雄遲暮 提交于 2019-11-28 09:38:21
I have recently started noticing the following warning when starting my JavaFX application: WARNING: Loading FXML document with JavaFX API of version 8.0.65 by JavaFX runtime of version 8.0.60 The FXML in question was created by Gluon Scene Builder 8.1.0, running with it's bundled Java, version 1.8.0_65. The application is launched with my OS Java, version 1.8.0_72. The root node of the FXML does have the attribute xmlns="http://javafx.com/javafx/8.0.65" but I figured 1.8.0_72 > 1.8.0_65, so why am I getting this message? Is it something I should be worried about? And is there a way to ask the