Swing-Problems with LayoutManagern and JCombobox

Hey!



I got a very strange problem when using JMEDesktop with a TableLayout and JComboBoxes.



Every klick on the Comboboxes throws this Exception at the Inputhandler.update Method:

05.03.2008 20:34:39 class com.jmex.awt.swingui.JMEDesktop onButton(swingButton, pressed, x, y)

SCHWERWIEGEND: Exception

java.lang.reflect.InvocationTargetException

at java.awt.EventQueue.invokeAndWait(Unknown Source)

at javax.swing.SwingUtilities.invokeAndWait(Unknown Source)

at com.jmex.awt.swingui.JMEDesktop.onButton(JMEDesktop.java:451)



at com.jme.input.InputHandler.update(InputHandler.java:406)

at optionmenu.OptionsMenu.update(OptionsMenu.java:140)

at com.jmex.game.state.GameStateNode.update(GameStateNode.java:71)

at com.jmex.game.StandardGame.update(StandardGame.java:323)

at com.jmex.game.StandardGame.run(StandardGame.java:198)

at java.lang.Thread.run(Unknown Source)

Caused by: java.lang.IllegalArgumentException: Cannot accept a constraint of class class java.lang.Integer

at info.clearthought.layout.TableLayout.addLayoutComponent(Unknown Source)

at java.awt.Container.addImpl(Unknown Source)

at javax.swing.JLayeredPane.addImpl(Unknown Source)

at javax.swing.JDesktopPane.addImpl(Unknown Source)







with borderlayout its a similar error. doesnt the JMEDesktop works with LayoutManagers?

I also tried it without a specified LayoutManager, but then the PopupWindows opens and collapses directly.

What am I doing wrong?



Than I got another strange thing i cant explain. It's when creating a new Gamestate and switching to that. Some times the JMEDesktop Elements arent drawn - only when the mouse is over the element.

I'm pretty new to the engine, so forgive my (possibly easy) questions :wink:



And before i post, how is the performance difference between using the Swing UI's and for example Feng GUI?



Thanks,

bye

Kain

There was (or maybe there still is) a known problem with JComboBox and jME…



http://www.jmonkeyengine.com/jmeforum/index.php?topic=5392.15

well, yes, the problem with the closing Combobox is fixed when using the jdk 6.0…



but it still won't work for other Layout Managers. Do i really need to use the NullLayout and set my Positions manually?

The exception looks like your swing components are configured in a wrong way. Check that they really work outside JMEDesktop (in a normal swing frame), first. I guess, they do not… if they do - no idea why it should not work in JMEDesktop.

i must say that they do - everything works fine within a JFrame.



i've also got problems when using a JGraph Component. There dragging arrows from one component to another doesnt work (but sometimes it does - very strange).

This application with the JGraph has worked on a JFrame too.



Thanks for your replys - very fast here :wink:

Kain said:

i must say that they do - everything works fine within a JFrame.

uh, ok. Layouters should work. Reading your first post again:
JMEDesktop with a TableLayout

Makes me a little suspicious, though. Did you really try it with a JDesktop in that JFrame? Or did you probably try to change the layouter of the JDesktop itself? Most likely that won't work. Add a panel or internal frame to the desktop and apply the layouter to that one.

oh^^



yes youre right, i tried to set the TableLayout directly to the JDesktop. Setting a JPanel between the desktop and my JCombobox everything works as it should :slight_smile:



Thanks!





but the problem with the JGraph is still the same, that doesnt like me :frowning:

(not even with a JPanel between the JGraph and the Layouter)



thats the exception in that case:

06.03.2008 16:33:09 class com.jmex.awt.swingui.JMEDesktop onMove(xDelta, yDelta, newX, newY)

SCHWERWIEGEND: Exception

java.lang.reflect.InvocationTargetException

at java.awt.EventQueue.invokeAndWait(EventQueue.java:997)

at javax.swing.SwingUtilities.invokeAndWait(SwingUtilities.java:1323)

at com.jmex.awt.swingui.JMEDesktop.onMove(JMEDesktop.java:489)



at GUI_T2.GUITest2.main(GUITest2.java:47)

Caused by: java.lang.UnsupportedOperationException

at com.jmex.awt.swingui.LWJGLImageGraphics.setTransform(LWJGLImageGraphics.java:850)

at org.jgraph.graph.EdgeView$EdgeHandle.overlay(Unknown Source)



at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:160)

at java.awt.EventDispatchThread.run(EventDispatchThread.java:121)



while dragging an arrow from one place to another.



maybe you could also answer my performance question?

use better swing with JMEDesktop or FengGUI or other libs?

That UnsupportedOperationException really means what it says: a function used by JGraph is unsupported by the JMEDesktop integration. If you do not implement it yourself (which is quite tricky) JGraph won't work properly.



Regarding performance, I can repeat what is said in many threads on the boards about it: Swing/JMEDesktop == a lot of garbage == slow if used e.g. for a frequently altered HUD. It's fine to use if you use it for a chat or in a game where fast huds are not an important thing. FengGUI (or other game specific gui libs) don't create that much garbage. Some people say it just give you a quick start…

And you need to distinguish between two approaches: draw directly to screen (like BUI) or draw to a texture (like JMEDesktop) and put that somewhere. Both have their pros and cons. (I'm not sure where FengGUI fit's there, direct drawing, I believe).