See the plug-in authoring kit for examples that use this library.
When a container is realized, the control objects that have been added to it will be converted into user interface widgets and laid out in a container. A given container can only be realized once; attempting to realize the container again will throw an exception.
Any kind of object may be added to an AbstractContainer. Interface components are added unchanged, and other objects are converted into an interface component when the container is realized. The standard conversions are as follows:
Some kinds of containers can have controls added with "hints" that affect how the control is laid out. Controls are added with hints using the place method. Adding controls using the add method will add it with a default hint (null).
| controls | an optional list of controls that will be added to the container |
returns true is this container has been realized
| text | the title to set |
This method is not defined in AbstractContainer and will throw an exception if called. Sublasses must override this method.
| control ... | controls to be added with the component's default placement rules |
returns this container
| control, hint ... | pairs of controls to be added and their associated placement hints |
returns this container
| index | the index of the control |
returns the requested control or throws an error if index is invalid
| index | the index of the control |
returns the requested control hint or throws an error if index is invalid
returns the number of added controls
| editor | the StrangeEonsEditor to add this to |
| title | an optional title for the tab that will be added |
| heartbeatListener | an optional function that is called every update heartbeat |
| fieldPopulationListener | an optional function that is called when the controls should be populated with data from the component |
| tabIndex | an optional index at which to insert the stack in the list of tabs |
returns the user interface element that contains the converted stack controls
| editor | the StrangeEonsEditor to search for a tab pane |
| -1 | dialog still open (possible if modeless), or user closed window |
| 0 | user pressed Cancel button |
| 1 | user pressed OK button |
JButton getOKButton()
Returns the dialog box's OK button (or null if it doesn't have one).
JButton getCancelButton()
Returns the dialog box's Cancel button (or null if it doesn't have one).
int showDialog()
Displays the dialog. If the dialog is modeless, the method returns
immediately. If it is modal, the script stops until the user closes
the dialog, and the returned value indicates the button used to close
the dialog (see the description of getCloseButton().
Component getContent()
Return the component that was realized by the container when the dialog
was created.
| title | an optional title for the dialog window |
| okText | optional text to use for the OK button; null for default text, "" to hide button |
| cancelText | optional text to use for the Cancel button; null for default text, "" to hide button |
| icon | an optional icon that will be placed next to the content (null for no icon) |
| modal | optional flag; if true, the script stops running until the dialog is closed |
returns the new dialog box
Creates a new Row container, which organizes controls into a horizontal row. Controls in this container will accept a non-negative numeric hint that adjusts the size of the gap between the hinted control and the previous control. The default hints will provide a gap of 0 for the first control and 1 for subsequent controls. Each unit of gap inserts a small indentation.
| control | a list of zero or more controls to be added to the new Row |
| alignment | the alignment value to set |
| control | a list of zero or more controls to be added to the new Stack |
| columns | the number of column grids |
| control | a list of zero or more controls to be added to the new Stack |
Example:
var grid = new Grid(); grid.place( "Name", "", textField(), "wrap, span, grow", "Ability", "", textField( "", 15 ), "grow", "Modifier", "", textField( "", 10 ), "grow" ); grid.createDialog().showDialog();
| layoutConstraints | optional global constraints on the layout |
| columnConstraints | optional constraints on the grid columns |
| rowConstraints | optional constraints on the grid rows |
returns a new Grid containter
| br | Insert a line break before this control |
| p | Insert a paragraph break before this control |
| tab | Align control to a tab stop |
| hfill | Cause control to fill the available horizontal space |
| vfill | Cause control to fill the available vertical space (may be used once per container) |
| left | Align subsequent controls to the left edge of the container (this is the default) |
| right | Align subsequent controls to the right edge of the container |
| center | Center subsequent controls horizontally |
| vtop | Align controls to the top of the container (this is the default) |
| vcenter | Align controls to the vertical center of the container |
Example:
var typeGrid = new TypeGrid(); typeGrid.place( "<html><b><u>Registration", "center", "Name", "p left", textField( "", 30 ), "tab hfill", "Age", "br", textField( "", 3 ), "tab", "Gender", "br", comboBox( ["Male","Female","Other"] ), "tab" ); typeGrid.createDialog( "Demo", "Register", null, null ).showDialog();
| layoutConstraints | optional global constraints on the layout |
| columnConstraints | optional constraints on the grid columns |
| rowConstraints | optional constraints on the grid rows |
returns a new Grid containter