I'm trying to understand how Apache Pivot builds a GUI from it's definition in a BXML file. I want to make sure that I understand which steps are involved and what is done automatically during these steps. For this, I tried translating a BXML definition for a very simple GUI to pure Java. But it seems that layouting is not done the same way (or at all) when following the steps that are described in the BXML Primer.
This is the BXML file and the accompanying class to load the file:
example.bxml:
<?xml version="1.0" encoding="UTF-8"?>
<Frame xmlns="org.apache.pivot.wtk">
<TextArea text="Hello World" />
</Frame>
WithBxml.java:
public final class WithBxml extends Application.Adapter {
@Override
public void startup(Display display, Map<String, String> properties) throws Exception {
Frame frame = (Frame) new BXMLSerializer().readObject(WithBxml.class, "example.bxml");
frame.open(display);
}
public static void main(String[] args) {
DesktopApplicationContext.main(WithBxml.class, args);
}
}
This creates the following GUI, which is expected:
I'm trying to use the following code to recreate the same GUI. But the TextArea
is not visible, as can be seen in the following screenshot.
WithoutBxml.java:
public final class WithoutBxml extends Application.Adapter {
@Override
public void startup(Display display, Map<String, String> properties) throws Exception {
TextArea textArea = new TextArea();
textArea.setText("Hello World");
Frame frame = new Frame();
frame.add(textArea);
frame.open(display);
}
public static void main(String[] args) {
DesktopApplicationContext.main(WithoutBxml.class, args);
}
}
What do I need to change in the class WithoutBxml
to get the same result as with the BXML file?