Beautifying JavaFX Script From NetBeans Using AutoIt

DZone 's Guide to

Beautifying JavaFX Script From NetBeans Using AutoIt

· Java Zone ·
Free Resource

NetBeans is the official IDE for JavaFX development. However, the latest v6.71 (or beta 6.8) of NetBeans is unable to beautify JavaFX Script (JfxScript) code as the “Format” option is not working (It just do nothing.  See Bug acknowledgement).

 Editors Note: This content was submitted by geekycoder

The code beautifier is one of the most important tools for learning and using  JavaFX as most raw code copied from Internet/ebook tends to be unformatted, making it hard to read and use. Performing manual format is just too tedious. So until the next NetBeans’s release, users have to resort to using painstakingly manual code formatting .

Code beautifier turn this (The following JfxScript code is formatted in NetBeans ! Read on to see how it’s done.)


into this


Introducing AutoIt Script

image AutoIt Script is a productive and powerful FREE Windows automation utility with scripting capability using a simple easy-to-use BASIC variant language. Now with AutoIt Script, users no longer have to sweat the formatting stuff.

Watch how AutoIt Script perform its magic.

AutoIt Script accomplishes it in just seconds.

How it works

The JavaScript code beautifier in NetBeans is surprisingly able to format the JfxScript code extremely well.  Therefore, AutoIt Script leverages on this “discovered” capability to automate the formatting by copying the JfxScript code to a opened Javascript file for beautifying, and then replace original code. This is all done through keystroke simulation, and takes just few seconds. With NetBeans’s undo feature, you can also undo the formatting instantly.



The following download includes the source code, dummy file and 32bit executable compiled script. If you need to run in 64bit, you need to download the AutoIt environment to either recompile the source or run the source with AutoIt interpreter.

Please perform the important steps before using the script.

You need to keymap the <Open File> menu Item to <Ctrl+F10> keys.

Go to:      

Tools –> Options –> KeyMapimage


Create a empty file called dummy.js or copy one from the following zip file  into <c:\temp> dir. This dummy file is used as a proxy to format code.

You can customize the keymap keys and dummy file through the script source from the following lines:

Local $keyBeautify = "^{F2}" ; Default to Ctnl + F2
local $keyOpenFile = "^{F10}" ; Open file, default to Ctnl + F10
Local $dummyJsFile = "c:\temp\dummy.js" ; Dummy JS file


If you experience some problems making it work, play around with the delay. Increase the delay in the sleep function (eg sleep(330) ). The argument is in millisec.


Unzip the following file and run <netbeans_beautify_jfxscript.exe>

The AutoIt trayicon (blue A icon) will appear. Now you can go to NetBeans source code editor and invoke <Ctnl+F2> to format the JfxScript code !

To exit, click on the icon again and choose Exit.

image image


Contents of file:


  code_beautifier.zip (272kb)


Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}