Substance look and feel - FAQ


Question 1 Can i use some / all of the code in Substance?
Answer Substance is released under BSD license. You are free to modify any part of the code as long as you mention the original license in the source code / the runnable distribution.

Question 2 Can i create my own look-and-feel on top of Substance?
Answer The code is written having this is mind. Most of the classes / functions are protected and not final, so you will be able to subclass them. This has not been tested, however. In case you see some method / class that is not accessible and you'd like to use, feel free to contact me.

Question 3 What is the policy for backwards binary and visual compatibility?
Answer The binary compatibility is intended to be complete for the supported properties and API. Other classes (such as SubstanceImageCreator or SubstanceCoreUtilities) are subject to change at any time. In case you are writing a Substance plugin and wish to use non-API functions, contact me so I will know about the functionality that you intend to use. The visual compatibility is much less enforced. From time to time you may see additional UI elements added on top of the existing components.

Question 4 Is it possible to backport Substance to 1.4?
Answer The current capabilities of tools such as Retrotranslator and Retroweaver do not support the new JDK-5.0 classes and functions that Substance uses (among them are MouseInfo and PointerInfo). In addition, a lot of UI-related bugs were fixed in JDK 5.0. See this article for more detailed explanation.

Question 5 I like some of the features, but the jar size is too big. How can i get a smaller runnable?
Answer In short - if you like the features, you pay the price. In long - you have a number of options:
  • Use lite version (available from release 2.2). It's about 220-230KB less.
  • Use special tools such as Stripper. Has been successfully tested - the jar size is cut by 25% (about 140KB less for full version, about 100KB less for lite version). Note that if you use this option, the stack traces of Substance defects will not contain line numbers. This may make it very difficult to reproduce and fix the defect.
  • Set compiler.debug property to "off". The result is the same as in the above option.
  • Use code obfuscators. Almost all classes and all non-private methods will need to have their names preserved.
  • Remove UI delegates for components that you don't use.
  • Fork the codebase and follow the moving target.
Substance provides not only a highly configurable "look" part. It also adds significant amount of features to the core Swing components. If you need this functionality, you can either use third-party components, write the functionality yourself or take Substance. In any case these features have to reside somewhere in the classpath. Having them in Substance enables you to use well-tested additional "feel" part of the core Swing components.

Question 6 Scrolling and moving windows leaves the watermark in inconsistent state. Is it a bug?
Answer No, it's by design. Swing does not repaint the component on every event while scrolling or moving the windows / frames / dialogs. Try it and watch the CPU go berserk. As by default the Substance watermarks are screen-bound, you may (and will) experience the watermark inconsistency. Here are some things you can do:
  • Define your scrolled component to be non-opaque. It will be repainted on every scroll, including the watermark. Doesn't really help with CPU if you have a lot of child components.
  • Add scroll / move listener and repaint the component there. It is recommended to call repaint every 100+ milliseconds to keep the application responsive. You will still experience "jagged" behaviour on fast scrolls / drags.
  • Use watermark-ignore property (see properties) on the specific component.
  • Use null watermark (see watermarks) for your application.
  • Use SubstanceLookAndFeel.setImageWatermarkKind(ImageWatermarkKind) or -Dsubstancelaf.watermark.image.kind and specify one of APP_ANCHOR, APP_CENTER or APP_TILE values for the image watermark kind. This is relevant only for image-based watermarks.

Question 7 I use an image-based watermark in my application / applet and don't see it. Is it a bug?
Answer By default, all Substance watermarks are screen-bound (also true under multiple screens). This is in order to enable smooth and seamless operation of applications that use multiple frames / dialogs. In addition, this allows to blend Substance-based applications on desktops with matching backgrounds. Specifically for image-based watermarks this may present a visual problem if the specified (local or remote) image is smaller than the screen (one or both dimensions). In this case the image is not enlarged and is centered in the middle of the screen. Unless your application is situated properly, the visual result is "no watermark". In order to amend the situation you will need to provide a larger image. Two notes:
  • If one or both dimensions of the watermark image are larger than the corresponding dimension(s) of the screen(s), the image will be scaled down.
  • In order to ensure seamless operation of applications that use multiple frames / dialogs under window move / drag see the answer to question 6 above.

Question 8 I don't like Substance.
Answer That's not really a question. If you don't like it, you can either help improve it by suggesting additional features in the forums and mailing lists, or use any other core or third-party look-and-feel. Here is an excellent list of all currently available third-patry LAFs.

Question 9 I requested the Project Owner / Developer / Content Developer role in this project. Why did you reject my request?
Answer Look-and-feel in general and Substance in particular require fairly advanced knowledge of Swing. This is not a playground / sandbox for experimenting with Swing - Substance aims to be a production-quality alternative to core and other third-party LAFs. As you wouldn't want a total stranger to be a part of your production team, you need first to establish yourself a worthy addition to this (or any other) project. You can start by requesting the Observer role, suggest new features, learn Substance codebase and propose ways to implement new features. After you show your skill and the will to stick with this project, you can expect a serious thought invested in answering the request for the Developer role. In addition, there is no need for Content Developer role in this project since I'm quite capable of maintaining a static HTML site by myself. The Project Owner role is granted only after certified analysis by three independent doctors that shows that the requester is in a lucid state of mind.

Question 10 Are there any known issues in Substance?
Answer See the known issues documentation. If you find an issue not mentioned in the above document, you can report it in either issue tracker, mailing lists, forums or direct mail to {kirillcool [@at@] yahoo [.dot.] com}.

Question 11 How can i use Substance on Mac and still have the standard Mac application toolbar?
Answer Use AWT menus. Thanks to Werner Randelshofer for the answer.

Question 12 I use animated GIFs as icons on internal frames and the CPU usage goes berserk (100% maxed out). Some parts of the application do not get repainted at all. What do i do?
Answer

When an animated GIF is set as an internal frame icon, the entire desktop pane is repainted on the GIF frame sequencing - not only the icon, not only the frame title pane and even not only that internal frame. Since Substance is much more CPU-intensive than Metal / Windows (it is partially addressed with the image caching), this results in severe CPU bottlenecks and refresh glitches on some controls. The call to repaint() doesn't necessarily cause an immediate repaint (this is what the paintImmediately() API is for). When the CPU is heavily loaded, most of the repaints will be skipped (coalesced). In extreme cases, the CPU is so heavily loaded that the repaint manager never gets to repaint some controls (such as combobox popup in a floating toolbar).

The best advice is to not use animated GIFs as icons. Thanks to Martin Clifford for pointing out this issue.


Question 13 What's going on with my cell renderers?
Answer

By design, Substance provides default renderers for trees, tables and lists that provide the following functionality:

  1. Respect the background color of the component.
  2. Provide alternating striped painting of background (table / list only).
  3. Provide theme-consistent rollover and selection highlighting.

Item 2 is available only on default renderers (SubstanceDefault*CellRenderer). If you use custom renderers that extend core classes, this functionality is not available out of the box. Item 3 is currently not configurable. This means that you can not have a table / tree / list without theme-consistent painting of selected / rolled-over cells unless you override the isOpaque() method to return true or override the paintComponent() and fill the background before calling super().


Question 14 Is there proper support for custom tab components in Mustang?
Answer

No. Since Substance minimum requirement is JDK 5.0, and the API to work with custom tab components is available only in 6.0, Substance doesn't provide any special support for custom tab components.


Question 15 I remove all references to my frame and Substance doesn't free the resources associated with this frame.
Answer This is a known problem and will be fixed in version 4.0. A workaround for this is to call dispose() method on the frames.

Question 16 Can i use Substance only for some parts of my UI?
Answer No. Substance in particular, and Java look and feels in general are not designed to be installed in the "mix and match" fashion.