fxml

How to resize automatically when loading an FXML into an AnchorPane?

此生再无相见时 提交于 2019-12-11 18:21:04
问题 I am having trouble with the layout of an FXML I load into an AnchorPane. I have a Scene.fxml with an AnchorPane and a button on it. Pressing the button loads the Internal.fxml into the AnchorPane. The Internal.fxml has a TextField with the AnchorPane Constraints set to left and right. That's about it. Though now when resizing the window the TextField does not resize. Why doesn't the TextField resize itself? Where is the error in the code below? Main.java: @Override public final void start

How to make the opened window must close at first before back to the main?

喜欢而已 提交于 2019-12-11 18:08:50
问题 I want to make that second window must close first like alert dialog. what should I add to this code when Button clicked: Parent parent = FXMLLoader.load(getClass().getResource("view/sec_win.fxml")); Stage stage = new Stage(); Scene scene = new Scene(parent); stage.setScene(scene); stage.show(); 回答1: There's a property called stage.initOwner(Stage stg) that allows this to happen. Example: public class JavaFXApplication4 extends Application { @Override public void start(Stage stage) { Button

Having an issue with javafx objects losing reference once they're put into an array

送分小仙女□ 提交于 2019-12-11 18:06:16
问题 So I'm trying to modify some circles in my controller class, and i've linked the circles to my fxml file circles but when i try to add them to a circle array for easy management, they seem to lose their reference. For example I have: @FXML private Circle circle1 = new Circle(); public void addNumber(ActionEvent event){ circle1.setLayoutX(355.0); circle1.setLayoutY(100.0); circle1.setVisbility(true); } The above method successfully makes a circle pop up in the given coordinates. However the

JavaFX. FXML loader can't find .fxml file in the project with modules

这一生的挚爱 提交于 2019-12-11 17:22:25
问题 I have a project with such structure: I trying to load sample.fxml from the Main class using this code: Parent root = FXMLLoader.load(Main.class.getResource("../../submodule/src/java/sample.fxml")); but it doesn't work. The sample.fxml file code is: <?import javafx.geometry.Insets?> <?import javafx.scene.layout.GridPane?> <?import javafx.scene.control.Button?> <?import javafx.scene.control.Label?> <GridPane fx:controller="sample.Controller" xmlns:fx="http://javafx.com/fxml" alignment="center"

JavaFx Include custom components in FXML

你。 提交于 2019-12-11 16:54:37
问题 i try to find a solution on how to include custom javafx objects to a fxml file. For example package myExtendedObjects; import javafx.scene.control.Label; public class MyLabel extends Label interface connected{ MyLabel(){ super(); } //Custom Code ... } into fxml <?import myExtendedObjects.myLabel?> <myLabel text="Name" /> i alsways get error codes from the type javafx.fxml.LoadException: Maybe there is a better solution then creating custom classes. But i need a Label with a custom Interface

JavaFX FXMLLoader InvocationTargetException?

亡梦爱人 提交于 2019-12-11 15:48:28
问题 I am trying to update some components situated in other Controller using FXMLLoader, When i run my code i get this exception : Exception in thread "JavaFX Application Thread" java.lang.RuntimeException: java.lang.reflect.InvocationTargetException at javafx.fxml.FXMLLoader$MethodHandler.invoke(FXMLLoader.java:1774) at javafx.fxml.FXMLLoader$ControllerMethodEventHandler.handle(FXMLLoader.java:1657) at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:86

Javafx ListView update dynamically

时光毁灭记忆、已成空白 提交于 2019-12-11 15:19:11
问题 I am creating a Chat application with JavaFx. My friend list is loaded into a ListView. My requirement is to show a notification icon when the user receives a message from a friend. For that I need to know the cell in which the friend is and also I need to show the notification icon. I cannot figure out a way to do this as I;m very new to FX. Any help would be appreciated. Thank you 回答1: Store the info about the friends you are notified about in some observable. This could be the item class

FXML: Alternate Uses

牧云@^-^@ 提交于 2019-12-11 14:49:51
问题 It is possible to use FXML to load non-GUI objects into memory? For example, I am creating a simple "voting" software for my school. All it needs is the list of "elective-posts" and the corresponding candidates along with other things like sets of "properties" of the posts and candidates. What I want to do is, that I write the data in a FXML file and then load it using a FXMLLoader . 回答1: Yes, FXML can be used to create arbitrary objects. You'd define the objects just like you would any GUI

TextArea ignore KeyEvent in JavaFX

£可爱£侵袭症+ 提交于 2019-12-11 14:05:19
问题 Java,JavaFX As in tittle, how can i force TextArea to ignore KeyEvent,and make sth instead of this KeyEvent. I should rather say that I would like to overwrite method which append a character from KeyEvent. Fo example: If i click 'k' on keyboard in the TextArea i would like it to be printed in console (not appended to TextArea) 回答1: Friend, try this: TextArea textArea = new TextArea(); textArea.addEventFilter(KeyEvent.KEY_TYPED, e -> { if (e.getCharacter().equals("k")) { e.consume(); } }); or

Reference and Guidelines for Dynamic Layout using JavaFX

淺唱寂寞╮ 提交于 2019-12-11 13:53:28
问题 I am using FXML via Scene Builder to establish some JavaFX scenes and formatting templates. Having scanned the web and Oracle tutorials, I still find determining the ' rules ' around how layouts size/wrap/fit-contents/etc. and spacing between elements and compoents to be 90% a black art to me. What I'm missing is the "layout overview" (missing chapter) that puts FXML (and JavaFX) layouts all together. If you've come across such a creature, please share link(s). To date I've only found small