Applet trouble

Hello,

I am trying to create my applet, it runs fine, using the LWJGL Loader, and when it says "Switching applet", I have to wait a little time and the cube doesn't appear until I click on the canvas…



How to simulate a click inside the canvas so it appears immediately please ?

Would it be better to use "display.setParent" instead of AWT ?



Using a laptop, Firefox 3, Windows Vista Premium, Intel Core 2 Duo 2.54, Nvidia GeFORCE 9800MGTX.



Thanks.

Yeah, it looks like it would be better to Display.setParent according to  this http://lwjgl.org/forum/index.php/topic,2820.msg15586.html#msg15586 and this http://lwjgl.org/forum/index.php/topic,2808.0.html.  I myself am going to try a JME Applet Implementation with this.  Don’t count on me though, try it yourself and see what you come up with.  If I get around to it maybe, we can compare code.

How to simulate a click inside the canvas so it appears immediately please ?


Try using the robot class ;)


        try{
            final java.awt.Robot robot = new java.awt.Robot();

            robot.mouseMove(
                    canvas.getLocationOnScreen().x + canvas.getWidth() / 2,
                    canvas.getLocationOnScreen().y + canvas.getHeight() / 2 );

            robot.mousePress( InputEvent.BUTTON1_MASK );
            robot.mouseRelease( InputEvent.BUTTON1_MASK );
        } catch( Exception e ){
        }

Using the mouse robot wouldn't work in this case since the applet freezes before it starts or has a chance to run its code, might work if you add it to lwjgl's applet loader code but again this isn't really a proper solutions.



If you like i can rewrite JME's SimpleJMEApplet's code to use the new LWJGL 2.0 Applets which run much faster and are more stable and most important of all don't suffer from AWT problems like this. Not really sure though what the process is to submit patches for the JME 2.0 code or if anyone here applies new patches?

Hey,

Thanks for your replies, robot mouse didn't work.



Faust, could you do it if it doesn't really disturb you and waste your time please ?



I'm pretty n00b at java at this time, I had a lot of patience to make that engine work into an applet (4-5 hours to understand the lwjgl and access denied errors…) and I don't really think I could get it to find out how to run the applet with display.setParent, because I don't understand how the hell it initializes itself and other stuff…



That would be the last thing I seriously need, if it would resolve that "freeze-until-click" problem.



Thanks alot !

Linaxys said:

Faust, could you do it if it doesn't really disturb you and waste your time please ?


k, i'll give it a shot tomorrow morning and post my results here.
Not really sure though what the process is to submit patches for the JME 2.0 code or if anyone here applies new patches?


You can either become a contributor, or just post the patch in the contribution depot and it will get committed by a developer or contributor.

Thanks faust, this would really help me too, I tried looking at it and it seems you have to change a lot, maybe you'll come up with something.  Good luck!  :slight_smile:

Looking at the code a bit more, I notice a couple things, there are only two types of JMECanvas, which utilize LWJGL, a AWT and a SWT version.  The AWT version (LWJGLCanvas.java) is nice, but in order to do the new Display.setParent in LWJGL 2.0 we'll either need to rewrite this because it uses AWTGLCanvas.  Or the another option is to somehow use the SWT version of LWJGL JMECanvas (LWJGLSWTCanvas.java) since it use GLCanvas?  Yet another option is to write a new JMECanvas entirely for this purpose and have it extend java.awt.Canvas like the new GearsApplet does.



Along the same lines, I think the functionality of Implementors for JMECanvas needs to be changed, since it's the Applet's method start in the new GearsApplet that causes the update.  I think this is right?

Hey,

I will try the options you've just said above once I get back to my home on Friday.



One other thing : How can I tile a texture on a giant plane please ?



Thanks.

Texture.setWrap( WrapMode.Repeat );
Texture.setScale( new Vector3f( 10, 10, 0 ) );



Will repeat' texture 10 times to either side...