User Interfaces with a ControlPanel¶
ControlPanel represents a container for GUI components, providing a flexible text editor-like layout manager. It allows the programmer to add components and to lay out them in the mathlet as easy as writing a text: the
ControlPanel’s height will be divided upon all lines where each of them can have a different horizontal alignment (left, right and center). Their height will be determined by the preferred sizes of their child components.
The ControlPanel is a base functionality of the
BaseApplet and all of its extending classes. In most cases it is positioned under the canvases (except for the
NoCanvasApplet: there it fills the whole vertical space). It can be accessed through
or used indirectly by one of the delegate methods defined in
BaseApplet. These delegaters are named after their implementations in the
It is possible to create a new ControlPanel-instance (e.g. in a standalone applet or in another user interface component) via
At the begin (means no object has been added yet) a "line pointer" starts at the first line and adds all following components to it. A line will be terminated by a line break. The pointer will then jump to the second line.
Note that line alignments can only be done for the current row.
It is possible to use tabstops and other space holders for a more exact positioning.
add(JComponent)– adds a component to the actual line’s end
addControl(JComponent)– same as
addText(String)– adds a TextPanel with the given text
addText(String, Color)– adds a TextPanel with the given text and color
addImage(String)– adds an image with the given file location
insertLineBreak()– jumps to the next line
insertTab()– inserts a single tabstop
insertHSpace(int)– inserts a place holder with
insertVSpace(int)– inserts a place holder with
setLeftAlignment(), setCenterAlignment(), setRightAlignment()– sets left/center/right alignment of the current and all following lines
setScrollable(boolean)– sets whether the
ControlPanelshould be scrollable
getCurrentLine()– returns the container for the current line
getLine(int n)– returns the container for the n-th line