tbone
Joined: 05 Nov 2009 Posts: 19
|
Posted: Mon Dec 28, 2009 7:18 am Post subject: Container/Box API Suggestion |
|
|
A pattern I have noticed when building GUIs with containers is this:
Code: |
VBox vb = new VBox(false, false);
add(vb);
with(vb) {
// create and add stuff in the VBox
}
|
Would it be possible update add, pack*, etc (which currently return void) to return the Widget that was passed to it? It would allow some fairly nice constructs like:
Code: |
with(add(new Vbox(false, false))) {
// do stuff with vbox
}
|
This could even be extended to other void returning methods to allow for chained construction (although I don't know if I'd use it).
Code: |
add(new VBox(false, false)).setSpacing(10).add(new HBox(false, false));
Label l = (new HBox).add(new Label("Hello World"));
|
Unless there are some other reasons not to do this. |
|