# 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 or 5.0?
Answer | The current capabilities of tools such as Retrotranslator and Retroweaver do not support the new Java 5.0 and 6.0 classes and functions that Substance is using. In addition, a lot of UI-related bugs were fixed in JDK 6.0.

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 510KB 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_VISIBLE` client property on the specific component, setting it to `Boolean.FALSE`
- Use null watermark (see watermarks) for your application.
- Use `SubstanceImageWatermark.setImageWatermarkKind(ImageWatermarkKind)` 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 menu bar?
Answer | The global Mac application menu bar is available only under menu UI delegates from the native Aqua look-and-feel. There are two options to have this functionality in your application.

- Use AWT menus. Thanks to Werner Randelshofer for this option.
- Use Aqua UI delegates for the menus and menu related classes. The recommended way to do this:
  1. Call `UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName())`.
  2. Query and store the `UIManager` entries for the following keys: MenuBarUI, MenuUI, MenuItemUI, CheckBoxMenuItemUI, RadioButtonMenuItemUI, PopupMenuUI.
  3. Set Substance as the look-and-feel.
  4. Before creating your first window, restore the `UIManager` entries for the keys specified in the second step.
  It is not recommended to rely on the current class names for the Aqua UI delegates, since the package that hosts these classes is different for different versions of Apple VM. This is mentioned in the release notes for Apple VM 1.6.0 on Mac OS X 10.5 Leopard (radar #4907470). Thanks to Sergiy Michka and Mike Swingler for this option.

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.

This functionality is only available on default Substance renderers in the `org.jvnet.substance.api.renderers`. If you use custom renderers that extend core Swing classes, you will not have it.

If you want to change the default animation settings on your lists, tables and trees (for example, to disable core Substance animations on custom application renderers) please consult the animation primer.

Question 14 | Is there proper support for custom tab components in Java 6?
Answer | Substance doesn't provide any special support for custom tab components.

Question 15 | 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.

Question 16 | How do i make Substance to paint the title panes?
Answer | In case you wish to use cross-platform frame and dialog decorations, use the following before you instantiate your first top-level window: JFrame.setDefaultLookAndFeelDecorated(true); and JDialog.setDefaultLookAndFeelDecorated(true);. This, however, causes flicker on resize due to a known Swing bug. For Windows, there is a workaround, using System.setProperty("sun.awt.noerasebackground", "true");. You can set this property along with the above two lines.