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.

javawindows_1.gif

javawindows_2.gif

javawindows_3.gif

javawindows_4.gif

Use with Graphics:

javawindows_5.gif

javawindows_6.gif

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.

javawindows_7.gif

javawindows_8.gif

javawindows_9.gif

The following example creates a new window with a the same plot as above, but sets a windows title "Tangent Function".

javawindows_10.gif

javawindows_11.gif

javawindows_12.gif

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".

javawindows_13.gif

javawindows_14.gif

javawindows_15.gif

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:

javawindows_16.gif

javawindows_17.gif

Get the frame height:

javawindows_18.gif

javawindows_19.gif

Get the title:

javawindows_20.gif

javawindows_21.gif

Set a new title:

javawindows_22.gif

javawindows_23.gif

Get screen coordinates of the current location:

javawindows_24.gif

javawindows_25.gif

Move to a new location on the screen:

javawindows_26.gif

Resize:

javawindows_27.gif

javawindows_28.gif

Add a menu bar (empty):

javawindows_29.gif

javawindows_30.gif

All this can, of course, be done programmatically as well.

Spikey Created with Wolfram Mathematica 8.0