Contents
Here is a step-by-step instruction to start building your application with swing-ui GUI module. If you find issues with these instructions, please report it as soon as possible.
Requirements
- Windows, Linux, or Mac
- Node.js 18+, Bun 1.1+, or Deno 2.6+. Check version with command
node -v,bun -v, anddeno -vrespectively. - Java 11+ JDK (Path to Java executable must be added to the system’s PATH environment variable). Check version with command
java -version. - Processor: 1Ghz or more (It even runs on a Raspberry Pi Zero $5 computer, just way slower than desired).
- RAM: 500MB or more
- Your app has to be ESM (ECMAScript Module).
swing-uidoesn’t support CommonJS.
NOTE: If java command is not found, make sure the path to Java executable is added to PATH environment variable. Optionally, you can specify a directory to your desired java executable with option --java-dir="JAVA_EXECUTABLE_DIRECTORY" or by setting JAVA_HOME environment variable. (for example, if you have multiple versions of java on your system and want to use a specific version).
Create a New Project
Choose your JavaScript runtime:
NOTE: This module should NOT be installed globally with -g flag. It should be installed locally for each project.
NOTE: In Windows it’s recommended to use an application like Bat To Exe Converter that creates a launcher executable (such as Run.exe) that would start the application without a terminal window. The executable can have a custom icon, custom command arguments, and is nice for deploying projects, especially for commercial applications when you would want to create a shortcut with the icon to the executable. Also, a free small command tool nircmd.exe can be used to start the node/bun/deno application without showing a terminal window. See our documentation for more ways to start your project without a terminal window.
Super Easy to Code
Your code to create a window with a button without using our visual UI designer can look like this:
import "swing-ui";
globalThis.mainForm = new Window("My new desktop app").size(500, 350).closeOperation(Window.CloseOperation.Exit).show();
let button1 = new Button("Click Me").addTo(mainForm).position(15,15).onAction(function(e){alert("You did it!");});… this is a preferred method for larger projects:
import "swing-ui";
class MainForm extends Window
{
constructor()
{
super();
this.visible(true).size(500, 350).closeOperation(Window.CloseOperation.Exit);
this.button1 = new Button("Click Me").addTo(this).position(15,15).onAction(function(e){this.text("You did it!");});
}
}
globalThis.mainForm = new MainForm();NOTE: Always keep a reference to every UI component object by assigning it to a variable or storing it in another object’s property. If all references to a component are lost, it becomes eligible for garbage collection and may be destroyed at an unpredictable time. When a component is added to a parent, the parent maintains an internal reference to it as a child. This ensures the component remains alive even if all other references are removed, until it is explicitly removed from the parent.
Easy JavaScript API Reference
We have compiled for you an API Reference, so you could find all available methods and properties of this module.
Report Bugs
Please report any bugs you find in this module or API reference. All reports will be reviewed and addressed as needed.

