Comments (7)
You may take a look and see if it is possible to make it FXML friendly. I thought about it too but I felt it is not that critical. I can still design the panel using FXML. When I add the FXML designed panel to its parent using code, I can then wrap it in a DecorationPane. I know it is not perfect but probably enough to cover most cases.
from jidefx-oss.
Indeed. The design of DecorationPanel
feels that it was made with programmatic usage in mind. And though I like direct API usages I've come to appreciate the easiness of FXML to quickly setup an UI. Take the following FXML for example
<?xml version="1.0" encoding="UTF-8"?>
<?import griffon.javafx.scene.layout.MigLayoutPane?>
<?import griffon.javafx.support.fontawesome.FontAwesomeIcon?>
<?import javafx.scene.control.ListView?>
<?import javafx.scene.control.TitledPane?>
<?import org.example.DecorationPane?>
<MigLayoutPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity"
xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1"
layout="fill" cols="[][grow 2][]"
fx:controller="org.example.SampleController">
<TitledPane collapsible="false" text="People">
<graphic>
<FontAwesomeIcon fontAwesome="fa_users"/>
</graphic>
<ListView fx:id="peopleView" prefWidth="200.0" prefHeight="190.0"/>
</TitledPane>
<TitledPane collapsible="false" text="Details">
<graphic>
<FontAwesomeIcon fontAwesome="fa_user"/>
</graphic>
<DecorationPane>
<MigLayoutPane fx:id="formPanel" layout="fill" cols="[::80][]" prefHeight="190.0"/>
</DecorationPane>
</TitledPane>
<TitledPane collapsible="false" text="Actions">
<graphic>
<FontAwesomeIcon fontAwesome="fa_star"/>
</graphic>
<MigLayoutPane fx:id="actionsPanel" layout="fill" prefHeight="190.0"/>
</TitledPane>
</MigLayoutPane>
The two innermost MigLayoutPane
instances will have their children set using the Java API as their content is dynamic. The DecorationPane
used here simply removes the default no-arg constructor to make a quick test. If the constructor is left in place then the class doing the FXML loading has to have references to the TitledPane
instances, create the MigLayoutPane
s and wrap them with DecoratorPane
. Not much of a change given that the loading class performs direct Java API usage anyway. But what if the contents of the MigLayoutPane
s were static? Then everything could be defined in the FXML.
from jidefx-oss.
I see. What exactly need to be done? A default constructor and being able to set the content on fly?
from jidefx-oss.
Yes. The current constructor defines lifecycle methods that must be called when content is added. I believe the following measures are needed to make DecorationPane
be FXML friendly:
- remove explicit constructor
- add setContent() method that applies content Node and runs the lifecycle. This method must make sure previous content is disposed gracefully -> additional lifecycle methods are needed to deregister listeners on old content.
- override getChildren() to force a single element on the list. This is to prevent someone from calling
decorationPane.getChildren.add(someRandomControl)
. If this is too troublesome then an entry on the javadoc should be added specifying this pane assumes a single child element and makes no guarantees if additional children are added.
from jidefx-oss.
Thanks for the explanation. It'd be possible although needs some work. Let me see if I can find time for it next week.
from jidefx-oss.
Actually the current constructor must stay in place, otherwise it breaks compatibility. The no-args constructor must be added; then rhe content wiring/unwiring. Next week there is a 2 day @hackergarten at Javaland. I hope to get some people interested in jidefx and improvs
from jidefx-oss.
Cool!
from jidefx-oss.
Related Issues (20)
- LocalDateField doesn't behave like DateField, and some bugs HOT 3
- Unable to compile using jdk 1.8.0_40-ea HOT 2
- Neither decorations nor errors show up on controls HOT 6
- java.lang.NoSuchMethodError on scroll event in formatted text field HOT 2
- java.lang.NullPointerException when trying to input text in FormattedTextField HOT 3
- Apply gradle license plugin
- Apply versions plugin
- Let demos be run from the command line
- Add gradle wrapper configuration HOT 1
- Configure code coverage
- Configure the clirr plugin
- Configure Travis-CI
- Configure coveralls plugin
- Write down usage guide
- Disable jar signing on local install HOT 3
- gradle build failure HOT 1
- Efxclipse usage HOT 1
- Not able to drag drop DoubleField
- "gradle" => Cannot cast org.gradle.api.DefaultTask_Decorated to org.gradle.api.tasks.Delete HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jidefx-oss.