By private message:
i am a student and i am wishing to create a game as a mobile application using jess
as jess is a rule engine we can make help of it to create rules for non-monotonic logic
connectivity between applets is done but connecting jess with those applets has become a problem
could you please help me how to get a connection created so that depending on the present rule it creates a new rule and displays it so that user can click the option and so on...... the game continues
plzzzzzz help me
Originally posted by Ernest Friedman-Hill:
Jess is just a Java library, like any other, and the manual includes many simple and complex examples of embedding Jess in Java programs. Using Jess in an applet (if we're talking about java.applet.Applet) could be as simple as
import jess.*;
...
Rete engine = new Rete(this);
engine.batch("rules.clp")
engine.run();
If you pass "this" (the applet) to the engine constructor, as shown here, Jess is even smart enough to know to look for the file "rules.clp" on the web server.
I don't know what you mean here by "connecting" -- linking within a single process, or connecting to a remote service? And as far as "depending on the present rule it creates a new rule", that's really too vague to help with. At some point you need to learn the rule language and start writing code; then I can help you with specific questions.
Originally posted by Gavin Tranter:
This is just a guess, bu the way in which the exit button is described is different to the way the start button is described.
One uses set and the other uses set location.
Have you tried copying the existing button and renaming and relocating?
Personally I would start with what works, and if there is a similar element, copy it, and then change its parameters and see what affect that has.
But then I dont have JESS so havent read the manual.
Gavin
Originally posted by Ernest Friedman-Hill:
Indeed, this isn't a Jess problem, but a Java GUI problem. I see lots of issues here, all of which have to do with the GUI code itself, irrespective of language.
First, as Gavin points out, Button doesn't have a "set" method, so you can't be calling it. setLocation() is, indeed, a valid method. This script would abort with an exception right there.
Secondly, you're putting AWT Buttons into a Swing JFrame; you're mixing toolkits, and you ought to be using JButton instead with your JFrame. This will work, it's just bad style and you'll have other problems down the road.
Third, using "setLocation" followed by add() to place buttons is a horrible practice; in Java, you should use a LayoutManager and let it decide where to place the components. But if you are going to use this technique, then you need to turn off the default layout manager by setting it to null; i.e.,
(?*f* setLayout nil)
otherwise, you're using the JFrame's default BorderLayout layout manager. Calling add() on the JFrame with one argument like this places the component in the CENTER location of the JFrame; calling it again replaces the previous CENTER component with a new one, which is why you'll only ever see one button here (and your carefully computed component dimensions will be ignored, anyway.)
If you're going to write GUI code in Jess rather than in Java -- and although it's certainly possible, I see no reason to do it here -- it's best to write the code in Java first, and get it working the way you like, and then translate it to Jess. That way the Java compiler, or your IDE, can point out many errors for you.
Originally posted by Ernest Friedman-Hill:
How to which which two GUI interfaces?
Originally posted by Ernest Friedman-Hill:
This chapter of the Jess manual is devoted to building GUIs in the Jess language; there are several examples of responding to button presses and other events.
Originally posted by Ernest Friedman-Hill:
You need to understand what you're doing first, and how you would write it in Java, before trying to write any kind of Java scripting code like this in Jess. Once you understand what you want to do in Java, and then how Jess scripting works, it's trivial to write your code in Jess. But it really sounds like your understanding of what you want to do in Java is very weak, and I think you need to work on your design. Get something working in Java, and then add Jess to the mix only after you have a better idea of what you're trying to accomplish.
Code to make a JFrame appear when a button is pressed is trivial in both Java and Jess, and in fact the page I pointed to shows exactly what to do, with detailed code examples. So somehow I think you must be looking for something else.
On the other hand, now that you've changed the description to "invoking one applet from another applet", that's a whole different ballgame. First of all, that phrase doesn't really mean anything clearly. Do you mean communicating between two applets on a single HTML page (that can be done; but it has nothing to do with Jess). Do you mean creating one applet from another (strictly, that's possible, but not really in a useful way.) I suspect what you actually mean is something about communicating between applets in two different web browsers, on two different machines -- and that's an enormous topic, and one that has nothing at all to do with Jess, or GUIs, or buttons, or Frames, or anything else you're asking about here. If your question has anything to do with this last topic, then you need to go do some reading on Java networking, and the browser security model, and all sorts of other stuff. You might start here.
[ April 15, 2008: Message edited by: Ernest Friedman-Hill ]
Originally posted by Ernest Friedman-Hill:
Much of this code is copied directly from the "Diagnostic Assistant" example from the textbook; I don't know that it's particularly applicable to playing a game. Furthermore, the code already contains a couple of examples of adding ActionListeners to components, so I'm really unclear as to why you're asking this particular question. But in any case, you'd define a function and put your frame-creating code into it; i.e.,
Then if you want to call this function when the button in ?*start* is pressed, you'd just say
Originally posted by bharadwaz somavarapu:
i am not asking for the button in the same frame
for example say
i have created a frames naming f1 and f2
now the main thing is that code of frame1 is at "f1.clp" and frame2 is in "f2.clp"
now if i press a button in f1.clp then i should get the f2 frame to be executed( or poped out) and destroying frame1
Originally posted by bharadwaz somavarapu:
why do i get errors when i tr to execute the files using rete object in java
[OCP 21 book] | [OCP 17 book] | [OCP 11 book] | [OCA 8 book] [OCP 8 book] [Practice tests book] [Blog] [JavaRanch FAQ] [How To Ask Questions] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
Consider Paul's rocket mass heater. |