Splitting a YAML file into separate ones

158 views
Skip to first unread message

Kohányi Róbert

unread,
Jul 13, 2011, 1:08:50 PM7/13/11
to JavaBuilders
I'd like to know how to split one YAML file into separate ones.

For example: I have a Main JFrame with a JTabbedPane and I have a
MyCustomJPanel with custom stuff and I want the latter to have a
separate YAML file.

# Main.yml
JFrame:
- name: main
- title: title
- content:
- JTabbedPane:
- name: tabs
- content:
- MyCustomJPanel: # I don't want to set
anything here, maybe the "name" field.

# MyCustomJPanel.yml
Now here I want to set everything related to my custom JPanel.

Is this possible? Am I approaching this right?

Thanks in advance!

Regards,
Kohányi Róbert

Jacek Furmankiewicz

unread,
Jul 13, 2011, 1:19:57 PM7/13/11
to javabu...@googlegroups.com
See the section in the book on custom components

MyCustomPanel is built separately via its own YAML.
The parent JFrame refers to MyCustomPanel and SwingJB just does a regular new() on it


--
You received this message because you are subscribed to the Google Groups "JavaBuilders" group.
To post to this group, send email to javabu...@googlegroups.com.
To unsubscribe from this group, send email to javabuilders...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/javabuilders?hl=en.


Róbert Kohányi

unread,
Jul 13, 2011, 1:51:53 PM7/13/11
to JavaBuilders
Yeah, the instantiation is working as expected, but this wasn't a problem anyway.

What I want to do is the following: move the configuration logic related to the custom JPanel entirely to its own YAML file.

# Main.yml
JFrame:
       - name: main
       - title: title
       - content:
               - JTabbedPane:
                       - name: tabs
                       - content:
                              <reference or import MyCustomPanel.yml>

# MyCustomJPanel.yml
MyCustomJPanel:
        - name: custom
        - tabTitle: something

I want to configure MyCustomJPanel in its own YAML file, not in the Main.yml. If I specify that the content of the JTabbedPane is MyCustomPanel then it gets instantiated, but the configuration will still be in the Main.yml and the stuff I wrote in MyCustomPanel.yml is ignored.

Maybe my explanation is hazy or I'm just approaching this from the wrong direction, but I really can't describe this more thoroughly.

Regards,
Kohányi Róbert


Jacek Furmankiewicz

unread,
Jul 13, 2011, 2:33:12 PM7/13/11
to javabu...@googlegroups.com
It's in the book...your Java class where you are calling the Main.yml from needs to have a private variable of type MyCustomPanel and that
is how we find the type via reflection. Plenty of examples in the sample app too
Reply all
Reply to author
Forward
0 new messages