Home pageFind It!Contact JeksJeks documentation

Jeks

 Jeks forum

This forum is dedicated to Jeks.
You may read freely the messages it contents. If you want to write a message or answer to a subject, subscribe to it first.

Subjects Recent messages Login Subscribe

Messages of subject A simple example

daviskessler

Location : Lexington, KY
Member since : Jun 20, 2003
Messages : 1
 Jun 20, 2003 at 8:22 PM
hey all, i was just wondering if anyone uses this forum. If its at all posibble, could someone send me the source code for a simple spreadsheet they wrote using Jeks. I'm fairly new to Java, and I'm still learning by looking at what others have done. Thanks

[Subject changed by moderator]

Manu

Location : Paris / France
Member since : Apr 29, 2003
Messages : 394
 Jun 21, 2003 at 10:39 AM
The simpliest example of a spreadsheet table displayed in a frame could be :
-------
import com.eteks.jeks.JeksTable;
import javax.swing.*;

public class TestJeks
{
public static void main (String args [])
{
JFrame frame = new JFrame ("Simple spreadsheet");
frame.getContentPane().add (new JScrollPane (new JeksTable ()));
frame.setSize (500, 300);
frame.setVisible (true);
}
}
-------
You may compile this class by adding jeks.jar to java classpath :
javac -classpath path/to/jeks.jar TestJeks.java

And run it by adding jeks.jar and jeksparser.jar to java classpath :
Under UNIX : java -classpath path/to/jeks.jar;path/to/jeksparser.jar:. TestJeks
Under Windows : java -classpath path/to/jeks.jar;path/to/jeksparser.jar;. TestJeks

jeks.jar and jeksparser.jar librairies can be found in the lib directory of Jeks.


If you look for an example using only the parser, here it is :
--------
import com.eteks.parser.*;
import javax.swing.*;

public class TestJeksParser
{
public static void main (String args []) throws CompilationException
{
String function = JOptionPane.showInputDialog ("Enter a function f(x)=... :");
// Compile the function with a Java syntax
CompiledFunction cf = new FunctionParser (new JavaSyntax ()).compileFunction (function);

String value = JOptionPane.showInputDialog ("Enter a value :");
// Compute the result of the function with the entered value
double result = cf.computeFunction (new double [] {Double.parseDouble (value)});
// Display the result
JOptionPane.showMessageDialog (null, "Result : " + result);
System.exit (0);
}
}
--------
You may compile this class by adding jeksparser.jar to java classpath :
javac -classpath path/to/jeksparser.jar TestJeksParser.java

And run it by adding jeksparser.jar to java classpath :
Under UNIX : java -classpath path/to/jeksparser.jar:. TestJeks
Under Windows : java -classpath path/to/jeksparser.jar;. TestJeks

You may test functions like these :
f(x)=x*x-2.5
sincos(z)=Math.sin(z)*Math.cos(z)
...
---
Manu (moderator/modérateur)


Home pageFind It!ContactTop

© Copyrights 1997-2023 eTeks - All rights reserved

JeksJeks documentation