public class DisplayJavaSE extends AbstractPlaceableJavaSE implements DisplayInterface
DisplayJavaSE is the implementation of the DisplayInterface that uses AWT and Swing classes. Values of the tokens arriving on the input channels in a text area on the screen. Each input token is written on a separate line. The input type can be of any type. Thus, string-valued tokens can be used to generate arbitrary textual output, at one token per line.
Note that because of complexities in Swing, if you resize the display window, then, unlike the plotters, the new size will not be persistent. That is, if you save the model and then re-open it, the new size is forgotten. To control the size, you should set the rowsDisplayed and columnsDisplayed parameters.
Note that this actor internally uses JTextArea, a Java Swing object that is known to consume large amounts of memory. It is not advisable to use this actor to log large output streams.
AbstractPlaceableJavaSE.WindowClosingAdapter
Modifier and Type | Field and Description |
---|---|
javax.swing.JTextArea |
textArea
The text area in which the data will be displayed.
|
_frame, _paneSize, _windowClosingAdapter, _windowProperties
Constructor and Description |
---|
DisplayJavaSE() |
Modifier and Type | Method and Description |
---|---|
void |
cleanUp()
Free up memory when closing.
|
void |
display(java.lang.String value)
Append the string value of the token to the text area
on the screen.
|
java.lang.Object |
getTextArea()
Return the object of the containing text area.
|
void |
init(Display displayActor)
Set the number of rows for the text area.
|
void |
openWindow()
Open the display window if it has not been opened.
|
void |
place(PortableContainer portableContainer)
Specify the container in which the data should be displayed.
|
void |
remove()
Remove the display from the current container, if there is one.
|
void |
setColumns(int numberOfColumns)
Set the desired number of columns of the textArea, if there is one.
|
void |
setRows(int numberOfRows)
Set the desired number of rows of the textArea, if there is one.
|
void |
setTitle(java.lang.String stringValue)
Set the title of the window.
|
_exportMoMLContents, init, setFrame
public transient javax.swing.JTextArea textArea
public void cleanUp()
cleanUp
in interface DisplayInterface
cleanUp
in class AbstractPlaceableJavaSE
public void display(java.lang.String value)
display
in interface DisplayInterface
value
- The string to be displayedpublic java.lang.Object getTextArea()
getTextArea
in interface DisplayInterface
public void init(Display displayActor) throws IllegalActionException, NameDuplicationException
init
in interface DisplayInterface
displayActor
- The display actor to be initialized.IllegalActionException
- If the entity cannot be contained
by the proposed container.NameDuplicationException
- If the container already has an
actor with this name.public void openWindow() throws IllegalActionException
openWindow
in interface DisplayInterface
IllegalActionException
- If there is a problem creating
the effigy and tableau.
This is executed in the Swing event thread.public void place(PortableContainer portableContainer)
place
in interface DisplayInterface
portableContainer
- The container into which to place the
text area, or null to specify that there is no current
container.public void remove()
remove
in interface DisplayInterface
public void setColumns(int numberOfColumns) throws IllegalActionException
setColumns
in interface DisplayInterface
numberOfColumns
- The new value of the attribute.IllegalActionException
- If the specified attribute
is rowsDisplayed and its value is not positive.public void setRows(int numberOfRows) throws IllegalActionException
setRows
in interface DisplayInterface
numberOfRows
- The new value of the attribute.IllegalActionException
- If the specified attribute
is rowsDisplayed and its value is not positive.public void setTitle(java.lang.String stringValue) throws IllegalActionException
If the title parameter is set to the empty string, and the Display window has been rendered, then the title of the Display window will be updated to the value of the name parameter.
This is executed in the Swing event thread.setTitle
in interface DisplayInterface
stringValue
- The title to be set.IllegalActionException
- If the title cannot be set.