Windows with Mathematica Output
JavaTools makes it easy to create new or modify existing windows with Mathematica output, such as graphics, formulae, or any other computed result.
JDisplayFunction
The function JDisplayFunction[] can be used as a $DisplayFunction in Plot and related plot/graphics functions. It creates a new window displaying the results of the Mathematica graphics expression.
Use with Graphics:
JWindow
The function JWindow[] creates a new window displaying the results of the Mathematica expression. It has three optional arguments, a window title, and two parameters for window height and width. It returns two references: one to the JFrame object and one to the MathGraphicsJPanel object in the Java virtual machine, which can be stored in a Mathematica symbol for further processing with JLink/Java, or as a "handle" for the JavaTools function JWindowSend[], see below.
The following example creates a new window with a plot of the tangent function, not using any window title and using default sizes for width and height.
The following example creates a new window with a the same plot as above, but sets a windows title "Tangent Function".
The following example takes the existing windows from the previous step and replaces its contents with a plot of the Sine function and replaces the title string with "Sine Function".
Further Processing of the Java Objects
A Java programmer could further analyse and process these two Java references as JavaTools fully exposes all underlying Java structures. The following requires a bit more Java knowledge and is only of interest to an advanced JLink/Java programmer.
Get the frame width:
Get the frame height:
Get the title:
Set a new title:
Get screen coordinates of the current location:
Move to a new location on the screen:
Resize:
Add a menu bar (empty):
All this can, of course, be done programmatically as well.