MathGroup Archive 2002

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: JavaPlot Window

  • To: mathgroup at smc.vnet.net
  • Subject: [mg36223] Re: [mg36188] JavaPlot Window
  • From: Werner Schuster <werner at sbox.tugraz.at>
  • Date: Tue, 27 Aug 2002 02:07:34 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

Jonathan Rockmann wrote:
> Does anyone know how to get the JavaPlot window (or any windows of this type)
> which can be seen at 
> http://www.wolfram.com/products/mathematica/newin42/java.html
> that WRI advertises comes with 4.2?

Well, I don't know if any tools (like that Window/Palette) written in 
Java are in the M_4.2 box, but if you know a little Java Programming, 
you can easily write something like that yourself; eg. using the 
MathGraphicsJPanel which allows you to display Mathematica Graphics
Expressions in a Java Component, simply by calling its setCommand()
Method (I hope that's correct, I am writing that from memory); 

eg. a simple JFrame with a MathGraphicsJPanel would be programmed like
this: 

(* This code is necessary for setting up J/Link *)
<<JLink`
InstallJava[ ]
(* now the GUI stuff *)
theJFrame = JavaNew["javax.swing.JFrame", "My Java Plot JFrame"];
theGraphicsPanel = JavaNew["com.wolfram.jlink.MathGraphicsJPanel"];
cp = theJFrame@getContentPane[];
cp@add[theGraphicsPanel];
theJFrame@pack[];
theJFrame@setVisible[True];
(* now set the Graphics Expression, using eg. a Plot command
passed in as a string*)
theGraphicsPanel@setCommand["Plot[Sin[x], {x, -1, 1}]"];

This should give you a Java Swing JFrame showing the result the Plot;
 (I hope this code works, I haven't tested it; for further information
look at the J/Link Userguide, which should cover just about every 
Question about J/Link); 

murphee


  • Prev by Date: RE: Obtaining sequences from lists of lists
  • Next by Date: RE: How to use inversefunction
  • Previous by thread: JavaPlot Window
  • Next by thread: Variable functions