I just tested creating a secondary window with a menu using UI.build(String);
SDL: myFrame.sdl
frame {
menus {
"Greetings" {
"Greet" do="hello"
}
}
form ID="MyFrame" {
}
}
Java: MyFrameController.java
public class MyFrameController extends FormController {
public void hello() {
System.out.println("Hello");
}
}
From within the AppController call:
JFrame frame = (JFrame)UI.build("myFrame");
frame.setVisible(true);
The menu will automatically be wired to the form controller associated
with the form set on the frame's content pane (i.e. MyFrame.) This is
the same special handling of menus and forms you see with
UI.startApplication();
If you need a reference to the controller and you have only the frame
that contains its form call:
MyFrameController controller =
(MyFrameController)((Form)frame.getContentPane()).getController();
The next release of SDL/Swing will make this easier by adding a
getTopLevelController() method to the frame.
Does this answer all your questions?
Dan
I was trying to use UI.getFormForComponent(frame) instead of
frame.getContentPane() in order to get the Form object.
On 06/03/2010 02:11 PM, Dan Leuck wrote:
Yes. That is true for windows in general. You either have to call
pack() or manually set their bounds before calling setVisible(true);
> Also, it doesn't look like shown() is being
> called on MyFrameController, but its easy enough to call it after getting
> the controller reference.
You are right. That is a bug that affects frames other than the main
application frame. We'll have it fixed for the next release. In the
meantime, as you indicated, you can just call it on the controller.
Best,
Dan