fxml

how to locate fxml from another package?

瘦欲@ 提交于 2019-12-30 04:29:05
问题 I have created a simple JavaFX application. It has two packages the main class is JFXTest2.java is in good package and the fxml and it's controller are in JFXTest2 package. now the problem is that i can not load the fxml in the main class. I tried loading the fxml like this: Parent root = FXMLLoader.load(getClass().getResource("jfxtest2.Screen.fxml")); and Parent root = FXMLLoader.load(getClass().getResource("jfxtest2/Screen.fxml")); and also Parent root = FXMLLoader.load(new URL("/jfxtest2

ProGuard breaks JavaFX application

本秂侑毒 提交于 2019-12-29 05:17:05
问题 I'm trying to obfuscate my JavaFX application but it fails. The generated result does not work and I do not understand why. The resulting jar just fails because the fxml file cannot load all imports anymore (ClassNotFoundException). The Deployment workflow: Build runnable jar (in IntelliJ knwon as an artifact) Obfuscate that jar with ProGuard Fix some issues in that jar that ProGuard fails to do 1) The minimal example application The example application 'GuardTest' is a IntelliJ project that

JavaFX 8 loading multiple fxml files into borderpane

风格不统一 提交于 2019-12-28 07:08:11
问题 Given the following code: public class Main extends Application { private BorderPane rootLayout; private VBox toolbarLayout; private URL path; public static void main(String[] args) { launch(args); } @Override public void start(Stage stage) { FXMLLoader loader = new FXMLLoader(); // Root View path = getClass().getResource("mainLayout.fxml"); try { loader.setLocation(path); rootLayout = (BorderPane) loader.load(); } catch (IOException e){ System.out.println("Not found: " + path); e

JavaFX - setVisible doesn't “hide” the element

拜拜、爱过 提交于 2019-12-28 05:06:05
问题 In JavaFX, if I have a scene with 2 VBox elements and each VBox has multiple Label in it. If I set the top VBox to invisible , why does the bottom VBox not move up the scene where the top VBox was ? The VBox is invisible but I would expect the other objects to move into its place. I am using FXML to load my controls. 回答1: Node.setVisible(boolean) just toggles the visibility state of a Node . To exclude a Node from its parents layout calculations you additionally have to set its managed state,

How to create custom components in JavaFX 2.0 using FXML?

好久不见. 提交于 2019-12-28 02:25:08
问题 I can't seem to find any material on the subject. To give a more concrete example, let's say I want to create a simple component that combines a checkbox and a label. Then, populate a ListView with instances of this custom component. UPDATE: see my answer for complete code UPDATE 2: For an up-to-date tutorial, please, consult the official documentation. There was a lot of new stuff that was added in 2.2. Finally, the Introduction to FXML covers pretty much everything you need to know about

ComboBox in JavaFX application doesn't show the data

江枫思渺然 提交于 2019-12-25 18:24:36
问题 I have class: public class Element { private final IntegerProperty id; private final StringProperty name; ...constructors... public Integer getId() { return id.get(); } public void setId(Integer id) { this.id.set(id); } public IntegerProperty idProperty() { return id; } public String getName() { return name.get(); } public void setName(String name) { this.name.set(name); } public StringProperty nameProperty() { return name; } @Override public String toString() { return name.get(); } And I try

Adding and selecting ChoiceBox that's inside a TableView

拜拜、爱过 提交于 2019-12-25 18:16:07
问题 So I'm trying to add a ChoiceBox for every variable inserted in the TableView. Users.java: Users(String userName , Integer userAge , ChoiceBox employed) { this.userName = userName ; this.userAge = userAge ; this.employed= employed; } //getters and setters Main.java: ObservableList<Users>userList = FXCollections.observableArrayList(); TableView<Users> userTable = new TableView(); TableColumn<Users, String> nameCol = new TableColumn(); TableColumn<Users, Integer> ageCol = new TableColumn();

Javafx TabPane with StackPane and custom Controls

拥有回忆 提交于 2019-12-25 17:26:06
问题 I'm developing an app in JAVAFX. Mainly, the app is using a TabPane controller. In the first tab, i'm loading a controller for a StackPane . In the StackPane i'm loading as a default, one list view with custom cells. In each cell i'm having some buttons. I want to add a new pane in the stack pane and bring it to front when a button is clicked. I tried with the toFront() and toBack() but i can't get anything working. I've check, and both panes are loaded and their content is the right one. I

FXML: Bind to nested field

こ雲淡風輕ζ 提交于 2019-12-25 09:17:10
问题 I have a TableColumn coded as: <TableColumn text="Nom" prefWidth="${purchasesTable.width*0.65}"> <cellValueFactory> <PropertyValueFactory property="item.name" /> </cellValueFactory> </TableColumn> it's TableView 's items property is bound to a list of Purchase class: Purchase class: public class Purchase { private Item item; public Item getItem() { return item; } public void setItem(Item item) { this.item = item; } } My Item class is as follows: public class Item { private long id; private

How can I make my StackPane take up the full vertical height of the window?

此生再无相见时 提交于 2019-12-25 08:49:46
问题 I'm trying to make the StackPane located in the <left> element of my main BorderPane take up the full vertical height of the window, even when its resized. How can I do this? This is what I've got so far: <?xml version="1.0" encoding="UTF-8"?> <?import javafx.scene.control.ListView?> <?import javafx.scene.control.MenuBar?> <?import javafx.scene.control.ScrollPane?> <?import javafx.scene.control.ToolBar?> <?import javafx.scene.Group?> <?import javafx.scene.image.Image?> <?import javafx.scene