Using javafx with fxml, and have a design question. I am using fxml to load my main components, so am loading fxml into nested scenes. The fxml files displayed depends on user action. My question is this:
Is it better to load all fxml into corresponding elements, then just update which element the parent is currently displaying? Or should I load the fxml only when the module it represents is called to be displayed?
Let me know what/if anything is unclear. I'm new to asking for help on my code and unsure if i have given enough info. Any resources or alternate suggestions welcome, thanks!
Related
We need a tree view with File system and check boxes in QT. Is there any way to achieve that?
The tree we need would look something like below:
UPDATE:
I am able to achieve it with subclass of QFileSystemModel. Still have few challenges, but at least subclass is working. Below is the code if anyone needs it. Below is the link to the code -
https://drive.google.com/file/d/1qViZ3iEW2pV2th0jQhzneDL14SEhIgS0/view?usp=sharing
The pending work is to apply a wait cursor (or make treeview uneditable when the check/uncheck is taking place).
PS: It will take a lot of time if root node is checked.
Well, all of that can be achieved with minimal customizations of built-in classes, actually those checkboxes is almost the only thing that has to be done yourself.
QFileSystemModel already provides a proper model for displaying the current filesystem contents, it can be subclassed
As for QML, the best demo is already provided by Qt, check the File System Browser Example. This example uses some deprecaded Qt functionality, but still it shows the basic concept.
The modern techniqes can be also found in the answers to the following question: Qt File Browser based on QML
Hopefully, all that helps you, good luck!
One of the issues I'm currently experiencing is that I can't seem to change the text of a Label which is implemented in a dynamically loaded AnchorPane. I assume this might be related to the controller and how JavaFX/TornadoFX works, but I can't seem to find what I'm doing wrong.
The issue itself occurs in this class, and happens in the showSystemDetails() method. What I would expect to happen is that upon pressing the "System Details" button in the sidebar, the labels would update to the required value, but this isn't happening for some reason.
Please feel free to point me to what I'm doing wrong, or provide any constructive criticism. The project is still in full development so a lot of things are still messy/broken.
The reason this isn't working is that you're manually loading a new version of the FMXL file every time you select something in your menu. The FXML file originally loaded by SystemDetailsViewProxy is updated correctly, but that's not the one you're showing on screen anymore.
To see the updated View, make sure you put the root node of the SystemDetailsViewProxy instance back.
You could for example change your DrawerMenuButton enum to contain references to SystemDetailsViewProxy::class instead of those two strings, and use add(viewClass) to add the correct root node to your view when clicking the menu buttons.
Furthermore, you should be using ViewModels and binding instead of manually updating the text property of the labels. You're doing an awful lot of manual/error prone work that the framework can help you with for free.
Your application is not using best practices in several important areas, and you're rolling your own solutions for stuff that the framework already does very well :)
Views are singletons when managed by the framework, but you instantiate them yourself instead of using inject/find. The result is that important life cycle methods are not being called.
I would also suggest looking into type safe builders instead of FXML.
Hope this helps :)
Do any developers use JavaFX alone over an FXML?
The benefits are obvious and of course knowing what the layout does is helpful. So I am wondering if there is any reason to learn about how the placement works and how everything works together behind the scenes of an FXML, as if I were to hard code it all?
I am trying to self teach myself somethings and I don't want to "half-ass" it. I coded very little in JavaFX, and used an FXML once, but if no one codes in JavaFX alone (or if there is any point to), maybe I'll just skip the process of learning about the code itself and jump right into the FXML
Sure it is possible to use JavaFX without FMXL!
But if you want to use FXML you could take a look at the Scene-Builder. Could be very useful and save you some time because you don't have to write all the FMXL yourself.
This thread should kind of answer your question too:
Java FX: declarative vs procedural
Hope this helps!
I'm trying to learn JavaFX 2.0 + FXML, and i found it kind of uncomfortable to make fxml file, without knowing what i can put in it and what i can't. I mean which tags are possible in FXML, which attributes evety tag has? which values evety attribute can have, and so on.
There are some examples in a web, but they don't show the hole capabilities of FXML.
I've tried to use NetBeans and Eclipse plugins for JavaFX 2.0, but, both of them does not have any intelences for FXML, they just validate open-close tags and other simple things, which evety XML editor can do. Maybe i've configured these plugins wrongly.
So, is there any documentatin with full reference (all tags, attributes and its possible values) of FXML?
FXML Reference
Introduction to FXML describes the syntax and usage patterns of the markup and is important to study when learning FXML. It does not define all elements usable in FXML.
There will never be a full reference (nor xml schema) for FXML as it works by reflecting on Java classes in the classpath and defining elements and attributes based on the properties of the classes.
FXML's creator (Greg Brown) suggests:
So currently Javadoc is the best reference.
For future Javadoc revisions of JavaFX, the JavaFX team is considering including FXML examples in the Javadoc.
This forum thread and this forum thread contains discussions about and links to fxml documentation.
FXML code completion in IDEs
NetBeans 7.3 provides FXML code completion.
The defacto JavaFX eclipse plugin e(fx)clipse provides FXML code completion.
Intellij Idea 12.1 provides FXML code completion.
These IDE inference engines work by reflecting on Java classes the same way the FXML implementation does.
When you use a library like ControlsFX, or develop your own JavaFX components, the IDE code completion is able to make use of the new classes and attributes you have created or linked.
To keep the answer updated here is the Javadoc for Javafx 8.
I just started out with Flex, and while I have worked with Actionscript2 for a few years, I'm still getting my head around Actionscript3. I've been diving into Flex for the past week, and can't figure this one thing out.
I am looking into the best way (or 'a' way) to allow me and other folks working on this project to easily create new themes for kind-of an video player. I show two videos, and need to be able to reposition them, style them, add images and anything else, really. I'm not looking to create a full-on templating engine, but if I could have a separate file/folder for each template, that would totally make my day.
I imagined having a solution in which I would have a folder inside src/templates/, and inside that folder I would have view.mxml that contains everything I need to display the videos. I would then be able to add other files such as images and such to make this template look the way it should.
Which template should be used should be defined by a variable in the main video file. This will either be provided to the swf file on playback, or provided by the video loading an external configuration file (but this is not part of my question :).
So, in short; How do I include mxml files that are inside one or two sub-folders inside src, and how do I do this in a way that the file I wish to include can be chosen via a variable.
Thanks so much in advance!
-Dave
You'd be surprised to what degree a Flex application can change its appearance through styling. Check out the following project:
http://www.fillcolors.com/
If you need more flexibility still, you could have an application with multiple views, one for each theme you want to show. An easy way to do this in Flex is to make use of the ViewStack component which basically layers view displays, showing only one at a given time.
As a very simple example, you could have something along these lines:
<mx:ViewStack selectedIndex="{currentIndex}">
<themes:CustomTheme1/>
<themes:CustomTheme2/>
<themes:CustomTheme3/>
</mx:ViewStack>
Here, currentIndex is a variable bound to the ViewStack, determining which of the three children is currently visible, each of which represent a custom MXML component (in your case, a theme).
Response to comment:
Yes, the above example is designed to do exactly that, but it's really not a feature of Flex, but of AS3. The CustomThemeX components are located using the themes namespace. The namespace is defined within the parent components root tag. In this example, the parent is a Canvas component:
<mx:Canvas xmlns:themes="themes">
This tells the compiler to look for these custom components within the themes sub-folder of your application; in other words, the src/themes folder, which contains the CustomThemeX components.
If the preceding paragraph didn't really sense to you, I'd recommend picking up a book/reading through the documentation about AS3/Flex and learning more about some of the core concepts of AS3 and object oriented programming. I wish I could help out more, but this question is starting to get a little too broad. I hope you understand. :)
I'm not an expert on Flex. But I've seen a tutorial on skins in Flex on gotoAndLearn.com. Maybe that kan give you some hints: Introduction to Flex: Part 3