AgentBase   AgentBase for SICStus
Components for Internet Programming
Version 2001-0.2-alpha

AgentBase Home > examples: jeval/jeval_eval.pl

  OVERVIEW
  Introduction
Download
Installation
FAQ

  EXAMPLES
  Web Server + CGI
Prolog + Java
Prolog + Java Applets
Applet Logic Monitor
Query-Eval via Telnet

  COMPONENTS
  Generic Server
HTTP Support
HTML Support
JEval Java Interface
Utilities

  RELATED
  SICStus Prolog Home
AgentBase 0.1-alpha


Page Formatted for Printing

Example - Jeval - single user GUI

This is a simple example of communication between Java and Prolog where Java is the server and prolog is the client.

Instructions

1. Change directory to jeval/ and start a jeval server with

java -jar jeval.jar

The server will listen for connections at port 7138.

2. Change directory to examples/jeval/ and start sicstus with

sicstus -l jeval_eval

Then start the jeval client with start.. It will connect to the server and send information about how its GUI should look like in Java code (BeanShell scripted). In this example it is the following code that describes the GUI:

   jeval:jeval('window=new JFrame("Jeval Demo");\c
                pane = window.getContentPane();\c
                pane.setLayout(new GridLayout(0,1));\c
                pane.add(new JLabel("Enter expression"));\c
                expr = new JTextField("5 * 7");\c
                pane.add(expr);\c
                result = new JLabel("Result:");\c
                pane.add(result);\c
                button = new JButton("Evaluate!");\c
                pane.add(button);\c
	        window.show();\c
	        window.pack();\c
	        window.setLocation(100, 100);\c
                jeval.addActionListener("button");\c
                jeval.addActionListener("expr");')

When you have successfully started the jeval_eval example you will see a small window looking like the screenshot below.

Source Code

The code of the Jeval example jeval_eval.pl.

Copyright © 2001 SICS AB, All Rights Reserved.
For more information about AgentBase please email agentbase@sics.se.