Swing to Nifty converter added to SDK

Tygron gaming released the WIP code of their Swing to Nifty converter and I added it to the SDK. You can now convert existing Swing GUI classes or ones created with the “GUI Builder” (Tools->Plugins) to Nifty XML files, within the limits of the current version of the importer.



The converter itself sits in Tools->NiftyGUI and can only be selected when a project is selected in the Project Explorer. When started, it will convert all swing classes in the project to Nifty XML files in the projects assets folder, under Interface/Converted. If the selected project is not a BasicGame project you will be asked to select a BasicGame project from the list of opened projects to save the XML files to. This allows creating a separate, normal “java” project with only the swing GUI code that can be transferred to the main project.



Don’t expect too much, its a WIP and GUI conversion isn’t exactly an easy topic I guess :slight_smile: Should be in the nightly build in a few hours.



Cheers,

Normen

3 Likes

This is excellent :). If only Swing didn’t have it’s own quirks that make me say “there’s no easy GUI system” :stuck_out_tongue:

Cool! Really looking forward to how it works.

This is really cool. I’ll keep an eye on this also!

Cool does this still work in RC2? It doesn’t seem to do anything

@Bonechilla said:
Cool does this still work in RC2? It doesn't seem to do anything

There have to be swing classes in your project.
@normen said:
There have to be swing classes in your project.


Yeah I was aware of that. I created a basic jFrame with a label that says helloWorld! in the netbeans editor; however, seemes to happen besides the Converted subdirectory being added to the Interface folder in the assets directory. I'm aware their are limitations and quickly checked their wiki but their instructions seemed pretty straight forward. Is their a specific format the Swing classes should be in?

Idk, do you get any stack traces ( warning sign in lower right )

@normen said:
Idk, do you get any stack traces ( warning sign in lower right )


Yes I actually just realized it a second ago. It claims that tygron lib is missing.
Code:
java.lang.NullPointerException at nl.tygron.niftyconverter.NiftyFactory.loadComponent(NiftyFactory.java:85) at nl.tygron.niftyconverter.NiftyFactory.loadComponentsFromDir(NiftyFactory.java:117) at nl.tygron.niftyconverter.NiftyFactory.loadComponents(NiftyFactory.java:94) Caused: java.lang.reflect.InvocationTargetException at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:601) [catch] at com.jme3.gde.gui.swing.ConvertToNifty.actionPerformed(ConvertToNifty.java:87) ......IRRELEVANT

Its easy to get the jar from their repo and just do it manually but I just figured I would report it since I just updated to RC2
@normen said:
No, where? The NiftyFactory seems to fail. Did you compile your project once? Else it cannot convert the swing files.


Clean built an ran a few times, even made the Swing class the main one inside a basic game project
@Bonechilla said:
Yes I actually just realized it a second ago. It claims that tygron lib is missing.
Code:
java.lang.NullPointerException at nl.tygron.niftyconverter.NiftyFactory.loadComponent(NiftyFactory.java:85) at nl.tygron.niftyconverter.NiftyFactory.loadComponentsFromDir(NiftyFactory.java:117) at nl.tygron.niftyconverter.NiftyFactory.loadComponents(NiftyFactory.java:94) Caused: java.lang.reflect.InvocationTargetException at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:601) [catch] at com.jme3.gde.gui.swing.ConvertToNifty.actionPerformed(ConvertToNifty.java:87) at org.openide.awt.InjectorExactlyOne.actionPerformed(InjectorExactlyOne.java:78) at org.openide.awt.ContextAction$Performer.actionPerformed(ContextAction.java:226) at org.openide.awt.ContextManager.actionPerformed(ContextManager.java:247) at org.openide.awt.ContextAction.actionPerformed(ContextAction.java:109) at org.openide.util.actions.ActionInvoker$1.run(ActionInvoker.java:93) at org.openide.util.actions.ActionInvoker.doPerformAction(ActionInvoker.java:116) at org.openide.util.actions.ActionInvoker.invokeAction(ActionInvoker.java:99) at org.openide.awt.GeneralAction$BaseDelAction.actionPerformed(GeneralAction.java:234) at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2018) at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2341) at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402) at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259) at javax.swing.AbstractButton.doClick(AbstractButton.java:376) at javax.swing.plaf.basic.BasicMenuItemUI.doClick(BasicMenuItemUI.java:833) at javax.swing.plaf.basic.BasicMenuItemUI$Handler.mouseReleased(BasicMenuItemUI.java:877) at java.awt.Component.processMouseEvent(Component.java:6505) at javax.swing.JComponent.processMouseEvent(JComponent.java:3321) at java.awt.Component.processEvent(Component.java:6270) at java.awt.Container.processEvent(Container.java:2229) at java.awt.Component.dispatchEventImpl(Component.java:4861) at java.awt.Container.dispatchEventImpl(Container.java:2287) at java.awt.Component.dispatchEvent(Component.java:4687) at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4832) at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4492) at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4422) at java.awt.Container.dispatchEventImpl(Container.java:2273) at java.awt.Component.dispatchEvent(Component.java:4687) at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:707) at java.awt.EventQueue.access$000(EventQueue.java:101) at java.awt.EventQueue$3.run(EventQueue.java:666) at java.awt.EventQueue$3.run(EventQueue.java:664) at java.security.AccessController.doPrivileged(Native Method) at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76) at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:87) at java.awt.EventQueue$4.run(EventQueue.java:680) at java.awt.EventQueue$4.run(EventQueue.java:678) at java.security.AccessController.doPrivileged(Native Method) at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76) at java.awt.EventQueue.dispatchEvent(EventQueue.java:677) at org.netbeans.core.TimableEventQueue.dispatchEvent(TimableEventQueue.java:158) at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:211) at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:128) at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:117) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:113) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:105) at java.awt.EventDispatchThread.run(EventDispatchThread.java:90)


No, where? The NiftyFactory seems to fail. Did you compile your project once? Else it cannot convert the swing files.

Then idk, honestly I also didn’t check the nifty converter for updates and/or issues.