I am the creator of Jess (not JESS, Jess; I'm officially required to tell you that this does not stand for "Java Expert System Shell" -- it's just a name, "Jess".) I can help you with general or specific questions about Jess (and all this other stuff too, actually, but so can lots of other people here.)

To get started, why not tell us what you know already from the list above. Have you written applets? Done network communication? Visited the Jess website (http://www.jessrules.com) and skimmed the manual? What do you know about game development? Let us know where you're at, and then we can try to help you from there.

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

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

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.

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

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.

I read the complete manual and i am familiar with many commanda but it is not being done when i am trying to add one more button to the same frame so please help me in finding my mistake in this code

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

ok thank you for correcting my mistakes but i want to implement in Jess and one more thing i succeded with your suggession

and how to connect the two gui interfaces in Jess now this is the main problem i am facing

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.

yes it is given about many of the gui interactings of the buttons but there is no example or atleast the header or the methods which are to be imported or called to invoke another applet from the present applet

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

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

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

baaru so

Greenhorn

Posts: 25

posted 9 years ago

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

one more thing to ask why do i get errors when i tr to execute the files using rete object in java i have imported all required files and even copied the jess.jar file to lib also even then its not getting executed whats problem with it...?

Originally posted by bharadwaz somavarapu: why do i get errors when i tr to execute the files using rete object in java

I don't know Jess, but I can tell there isn't enough information in this post for anyone to answer your question. Be sure to "Tell the Details" when you have a question. For example, post the errors you get when asking why you get the errors. See my signature for more on asking good questions.