Thread Locked This thread is locked - replies are not allowed.

Permlink Replies: 5 - Pages: 1 - Last Post: 7 Jun 24, 14:34 Last Post By: JeffTucker

Posts: 8,091
Registered: 31-Jan-2006
Compiling a skin's user interface
Posted: 16 Dec 18, 05:25
Compiling your skin's user interface has two advantages. First, the skin will load faster. For a skin with simple options, the difference isn't noticeable, but for a skin with a lot of panels and fields, it can make quite a difference. Second, working in an IDE like NetBeans will warn you about things like syntax errors, misspelled variable names, and so on, so that you can correct them before you ever compile the interface. With an interpreted onload.bsh or onload.groovy, it's more a matter of "modify, see if it crashes when you load the skin, try to figure out why, modify again...."

So, some instructions, and the source files for a basic DemoSkin skin that can serve as a model. Pathnames assume Windows - in macOS, things naturally won't be in the same places. Questions? Please post them in Skin development.

Step one, installing the Java JDK, JavaFX SDK, and NetBeans.

  • Install OpenJDK 22: This has no installers, alas. Unzip the file, and move the extracted jdk-22.0.1 folder to C:\Program Files\Java\.
  • Install OpenJFX SDK: Ditto on the lack of installers - unzip and move the extracted javafx-sdk-22.0.1 folder to C:\Program Files\Java\.
  • Download and install NetBeans from
  • The NetBeans installer won't be able to find JDK 22, because it wasn't "installed" by Windows. You must run the installer from the command line, and tell it where to find JDK 22:
    C:\Users\yourusername\Downloads\Apache-NetBeans-22-bin-windows-x64.exe --javahome "C:\Program Files\Java\jdk-22.0.1"
  • You can save some installation space by customizing the installation and de-selecting the PHP and Java EE modules, which aren't needed for compiling a jAlbum skin user interface.

Edited by: JeffTucker on 7 Jun 2024, 08:32 - Java and NetBeans versions

Posts: 8,091
Registered: 31-Jan-2006
Re: Compiling a skin's user interface
Posted: 16 Dec 18, 05:31   in response to: JeffTucker in response to: JeffTucker
Attachment (156 bytes)
Attachment (214 bytes)
Attachment (5.0 KB)
Attachment (3.4 KB)
Step two, setting up the project.

  • Launch NetBeans.
  • Choose File, New Project.
  • Choose Java with Ant, Java Class Library.
  • Name the project - for example DemoSkin. If you want to name the project for your own skin instead, like MySkin, change all references in the following instructions and in the attached source files to match that name.
  • In the Projects pane, right-click DemoSkin, and choose Properties.
  • Under Sources, go to Source/Binary Format, and choose JDK 14. This will make it possible for users of older versions of jAlbum to use the skin.
  • Under Libraries, go to Java Platform, and choose JDK 22.
  • Under Libraries, Compile, click the plus sign next to Classpath, choose Add JAR/Folder, navigate to C:\Program Files\jAlbum\lib and choose jalbum-core.jar.
  • Click the plus sign next to Classpath again, choose Add JAR/Folder, navigate to C:\Program Files\Java\javafx-sdk-22\lib and choose
  • Under Build, Packaging, check both Compress JAR File and Build JAR after Compiling.
  • OK out of Properties.
  • In the Projects pane, right-click Source Packages and choose New, Java Class.
  • Create a new Java class named DemoSkin and click Finish. Repeat, and create one named SkinModel.
  • If you're also going to create a custom UI panel, i.e., a panel for applying some settings to individual images or folders, which appears on the right side when you're in "edit" mode for an image or folder, create two more new Java classes, one named DemoSkinCustom and one named SlideModel. For a real-world example of a custom UI, see
  • Copy the contents of the attached source files to the appropriate source classes in NetBeans. You could, instead, exit NetBeans, then in Windows Explorer or Finder, replace the four files under NetBeansProjects\Sources\DemoSkin\src with the attached files.
  • In each of the source files you have just created, hit ALT-SHIFT-F to clean up the formatting.

Posts: 8,091
Registered: 31-Jan-2006
Re: Compiling a skin's user interface
Posted: 16 Dec 18, 05:32   in response to: JeffTucker in response to: JeffTucker
Attachment (490 bytes)
Step three, compiling and copying to your skin.

  • If you're not seeing any red error markers, you're ready to compile. Click the "hammer" icon in the toolbar. You will get one compiler warning about the classpath - ignore it.
  • Outside of NetBeans, navigate to NetBeansProjects\DemoSkin\dist, and copy DemoSkin.jar to the lib subdirectory of your skin directory.
  • In your skin directory, your onload.bsh or onload.groovy should be just a one-liner:
    new DemoSkin(engine);
  • Copy the attached file to your skin directory. For the About tab in the UI, the UI needs a few things, like a version number, an author, a home page, and a link to the forum section.
  • Launch jAlbum and choose your skin.
  • Before going "final" with your skin, it's a good idea to do a "clean and compile," using the "hammer and broom" icon. This gets rid of leftover classes (which often result when you've been changing panel configurations in your skin), and may result in a smaller .jar file.

Posts: 8,091
Registered: 31-Jan-2006
Re: Compiling a skin's user interface
Posted: 16 Dec 18, 05:33   in response to: JeffTucker in response to: JeffTucker
Step four, taking your existing skin's UI and converting it.

You'll need to stash your original onload.bsh somewhere so that you can copy things out of it.

If you try to copy your entire existing onload.bsh into NetBeans, you'll be chasing down problems forever, without being able to compile the UI until all the errors are fixed. I would suggest, instead, that you tackle one of your existing panels at a time. Define the variables in the source file (type and default value), then edit to define the UI fields, set up the StateMonitor()'s (if any), and lay out the panel.

My example uses anonymous inner classes, which I find much easier to maintain - it lets you move things from one panel to another without having to edit every reference to a variable that's on the panel. No more ui.varName or panelName.varName. If you use anonymous inner classes in onload.bsh, skin loading can be very slow, but in a compiled UI it's not an issue.

A lot of things are pretty much the same in a compiled UI as they are in an interpreted one, though Java is fussier about things like data typing than BeanShell is.

At any time, you can clean up your formatting by hitting ALT-SHIFT-F. You can automatically insert any missing imports with CTRL-SHIFT-I.

When you're ready to compile (don't even try it if there are any red error markers in NetBeans - it won't compile), click the hammer icon on the toolbar. When compilation is complete, copy NetBeansProjects\YourSkin\dist\YourSkin.jar to your skin's lib directory.

Do my examples show the only way to do things, or even the absolute best way? Not at all. They just show how I'm doing things in my skins, and these approaches work for me. Keeping things grouped the way they are (field definitions, monitors, layout, etc.) tends to keep me out of "improperly nested hell." And yes, you will find yourself there at some stage of the game. One thing to remember - when you enter an opening curly brace in NetBeans, it will automatically supply the closing one. But control panel definitions also require a closing semi-colon, which you have to enter manually. So before you even start populating a control panel with fields, close the sucker - that will cut down on the "endless red markers" phenomenon.

If you're wondering how to do some of the fancier things you might see in my skin's UI's, the source files are all bundled with the skins - burrow down into the skin directory to find the files.

Posts: 8,091
Registered: 31-Jan-2006
Re: Compiling a skin's user interface
Posted: 16 Dec 18, 05:39   in response to: JeffTucker in response to: JeffTucker
So, is this all worth the effort? Yes. Absolutely yes. The initial hurdle is large, but once you've done it, you're home-free. It is much easier to maintain a compiled UI than it is to maintain an interpreted onload.bsh.

You won't spend endless time hunting down the little typo that's preventing your skin from loading - in NetBeans, the second you mis-type a variable name, you'll get a red underline that alerts you to the error.

You won't have to head-scratch when your failure to include a toString() when you're checking a user choice causes mysterious errors. NetBeans will warn you about a data type mismatch.

And your skin will load in a fraction of the time.

Posts: 8,091
Registered: 31-Jan-2006
Re: Compiling a skin's user interface
Posted: 28 Feb 21, 14:07   in response to: JeffTucker in response to: JeffTucker
Attachment compiledest.png (66.9 KB)
One little time-saving tip: you can set up your NetBeans project so that it compiles the skin interface directly into the live version of the skin in jAlbum. See the attached screenshot. This eliminates the step of copying and pasting the .jar file. Just remember that there's no "undo" command, so keep a backup of your unmodified skin.

If you do this, you can, with jAlbum running, compile the skin, go to jAlbum, hit CTRL-R to reload the skin, and test the results.

But if you do this, you can't do the final clean and compile with jAlbum running, because the skin's lib directory is locked against deletion. Close jAlbum before doing this final compile.
Forum admins
Helpful Answer
Correct Answer

Point your RSS reader here for a feed of the latest messages in all forums