JMEDesktop: Swing within jME scene

wakeboardin said:

just wondering but could this be used like the gui in doom 3?

If you mean displays mounted to walls and machnies - yes, as Sion said, that can be done quite easily  :)

neato  :smiley:

irrisor said:

@Galun: half transparent? sure! - just do it like that text node

The setColor with alpha works fine. :)

irrisor said:

html-links: I don't know if I find the time to look at it soon. Most probably some mouse events are fired different by JMEDesktop than by a normal Swing Window. You can add a awt event listener at the toolkit and compare the event within your applet and in jME to get a clue...

I did so and the MouseEvent MOUSE_CLICKED is missing in JMEDesktop. PRESSED and RELEASED events are there. If I just knew what to do with that finding...

I tried to implement a CLICKED and with the following patch there is one but it seems the component is wrong as I still do not get any suitable event on the link listener: http://www.world-of-mystery.de/download/JMEDesktop.patch
Galun said:

I did so and the MouseEvent MOUSE_CLICKED is missing in JMEDesktop.

Oh, right, sorry! I knew there were missing, but as they were not needed for buttons I simply forgot them. CLICKED events are in - slightly different than your patch and working with Hyperlinks :)

I tried to combine JMEDesktop and an InputHandler like the FirstPersonHandler. The middle mouse button toggles between relative and absolute mouse movements. This works basicly but I have two problems:



A JEditorPane contains <a href> links that I cannot click as there are only ENTER and EXITED events. In TestJMEDesktop this works fine so it might be something with my custom input handler.



One of the frames in the desktop contains a JTextField which should have the focus as long as no other widget is there. I tried a grabFocus() on that but it won't get any keyboard events as long as the control is in relative mouse mode. The next try was to dispatch keyboard events received in the keyboard handler to the JTextField but this didn't work. It seems the char is the same but the codes are different.

If you need to convert key codes from lwjgl to awt (or back) you might check out the com.jmex.awt.input.AWTKeyInput class.  It has a couple static methods for doing this.

Ah, thanks. That helps.  I now have a (quite ugly) event translater working so that I can type in the JTextField while the custom InputHandler has control.

Dispatching a Return to JTextField or an ActionEvent does not trigger an ActionEvent when JMEDesktop is not focus owner and even forcing with grabFocus() does not help.

Maybe using the JMEDektop.sendAWTKeyEvent() would help but that is private.



If the JTextField has the focus (with switched off custom InputHandler) pressing return fires an ActionEvent as expected.

You can use yourJMEDesktop.setFocus( yourTextField ) to focus a component. requestFocus and alike methods do not work -> then JMEDesktop does the conversion and event handling for you.

I think, I'm on the wrong track. Calling desktop.setFocusOwner(chatField) where desktop is the JMEDesktop and chatField is the JTextField raises a "IllegalStateException: not in swing thread!".

Ah, yes, you have to do everything that accesses swing stuff in a direct way (e.g. creating, adding, manipulating components) in the swing thread! To do this from the jme update method use e.g. SwingUtils.invokeAndWait or invokeLater. (btw. that is the case in any swing application)

Now input into JTextField AND FirstPersonHandler works! Thanks.



Edit: the obligatory "thanks-it-works-screenshot" : http://www.world-of-mystery.de/download/screen00015.png

Hey, looks nice with that transparency!



Non-system cursor support and CLICKED events within JInternalFrames are in CVS - so 'freezing' and problems with link activiation should be solved.

Confirmed, the HTML links are working now with latest CVS.



Thanks, that's a big step towards the gui for my game. :slight_smile:



Edit: Oops. http://www.world-of-mystery.de/download/screen00016.png :slight_smile:

I don’t know if you’d be interested in this, but I wrote a neat little class that handles the display of messages in-game called JMessageDisplay.  It is in CVS for my jcommon project (http://jcommon.dev.java.net) under org.jcommon.swing.JMessageDisplay.  I’m currently implementing it into Roll-A-Rama for chat and event messages so they can appear in different fonts, colors, etc and they have a expiration timeout so they only exist for a certain amount of time and then fade out from the screen.  The fade-out looks particularly nice and it has an update method that should be called from your game’s update method.  Not sure if it would be useful to anyone else, but it gives a similar effect (in many ways I think better) to the way messages appear in most FPS games (ex. Battlefield 2) scrolling up from the bottom in the lower left corner of the screen and then disapearing after a certain amount of time depending on what type of message it was.



darkfrog

found out that it's the glTexSubImage2D that it hangs on…only when updating dirty regions on the lower left half of the screen though…really really strange…i get uncleaned dirt when dragging window on the lower left half of the screen…

I don't have a clue what could cause that - especially I'm not able to reproduce it anywhere - seems you are still on your own  :expressionless:

As a workaround for keybinding problems in JDK1.5, I added a JInternalFrame around the desktop. As I suspect this to be platform dependent again, please check if everything is still working smooth.

Hmm, unfortunately the latest code in CVS does not even show the JMEDesktop in the scene anymore on Mac.

Wha! That’s bad :’( - if I only had a Mac!



I disabled that fix for mac until I have a chance to test it on a mac and find a better solution…