Frequently Asked Questions
General
1. How do I integrate and enable Synthetica in my application?
2. Why do text components ignore non-opaque settings?
3. Why does my app window flicker while resizing?
4. How can I enable logging to see which images being loaded?
5. Why switching look and feel during runtime can cause problems?
6. Why is my text area component opaque even if set non-opaque?
7. Why a JFrame hides the OS TaskBar when being displayed maximized via JFrame#setExtendedState()?
8. How to enable hiding/overlapping the OS TaskBar when a window becomes maximized?
9. Why does maximizing windows in multiscreen environments on Linux fail?
10. Why does the frame icon of my JInternalFrame disappear as soon as the frame is iconified?
11. How can I modify the size of toolbar separators?
12. How can I disable the popup menu blur effect for SyntheticaMetallic themes?
13. How can I use Synthetica in an Applet or Web Start application?
14. How can I display a frame icon and system menu for JDialogs?
15. How can I colorize a JComponent/JButton?
16. How can I enable the screenMenuBar support on Mac OSX?
17. Sometimes my application isn't completely repainted - what's going wrong?
18. How can I render my own logo in the window title panel?
19. How can I disable toolBar background painting?
20. How can I improve drag performance for JInternalFrames?
21. Why is the background color for a JTabbedpane child component ignored?
22. Does Syntetica support the Java Module System JPMS?
23. I'm getting an IllegalAccessError or illegal reflective access warning - what's going wrong?
2. Why do text components ignore non-opaque settings?
3. Why does my app window flicker while resizing?
4. How can I enable logging to see which images being loaded?
5. Why switching look and feel during runtime can cause problems?
6. Why is my text area component opaque even if set non-opaque?
7. Why a JFrame hides the OS TaskBar when being displayed maximized via JFrame#setExtendedState()?
8. How to enable hiding/overlapping the OS TaskBar when a window becomes maximized?
9. Why does maximizing windows in multiscreen environments on Linux fail?
10. Why does the frame icon of my JInternalFrame disappear as soon as the frame is iconified?
11. How can I modify the size of toolbar separators?
12. How can I disable the popup menu blur effect for SyntheticaMetallic themes?
13. How can I use Synthetica in an Applet or Web Start application?
14. How can I display a frame icon and system menu for JDialogs?
15. How can I colorize a JComponent/JButton?
16. How can I enable the screenMenuBar support on Mac OSX?
17. Sometimes my application isn't completely repainted - what's going wrong?
18. How can I render my own logo in the window title panel?
19. How can I disable toolBar background painting?
20. How can I improve drag performance for JInternalFrames?
21. Why is the background color for a JTabbedpane child component ignored?
22. Does Syntetica support the Java Module System JPMS?
23. I'm getting an IllegalAccessError or illegal reflective access warning - what's going wrong?
Window Decoration
1. How can I enable native window decoration?
2. Synthetica's window decoration does not appear - why?
3. How can I completely disable window decoration?
2. Synthetica's window decoration does not appear - why?
3. How can I completely disable window decoration?
File Chooser
1. How can I disable the extended FileChooser component?
2. How can I configure the extended FileChooser not to remember preferences?
3. How can I improve the performance of the FileChooser
4. Sometimes my application freeze when the FileChooser appears - what can I do?
2. How can I configure the extended FileChooser not to remember preferences?
3. How can I improve the performance of the FileChooser
4. Sometimes my application freeze when the FileChooser appears - what can I do?
Font
1. How can I change the default font programmatically?
2. How can I enable font anti-aliasing?
3. Which font is used on platforms where my configured font doesn't exist?
4. Non-Western (Chinese and Japanese) characters won't get displayed - why?
5. How can I disable Synthetica's default font for a component instance?
2. How can I enable font anti-aliasing?
3. Which font is used on platforms where my configured font doesn't exist?
4. Non-Western (Chinese and Japanese) characters won't get displayed - why?
5. How can I disable Synthetica's default font for a component instance?
Renderer
1. How can I set my own JTable header renderer without loosing Synthetica's header style?
2. Why is the selection color of my customized TableCellRenderer ignored?
2. Why is the selection color of my customized TableCellRenderer ignored?
Customization
1. How can I customize an existing Synthetica Look and Feel?
2. How can I create a custom style and apply it to a component instance?
3. How can I create mixed styles for a JTabbedPane?
4. How can I add an additional style for a JTabbedPane?
5. The configured background image for text components doesn't appear - what's wrong?
6. How can I rename arrow buttons for customization?
2. How can I create a custom style and apply it to a component instance?
3. How can I create mixed styles for a JTabbedPane?
4. How can I add an additional style for a JTabbedPane?
5. The configured background image for text components doesn't appear - what's wrong?
6. How can I rename arrow buttons for customization?
General
1. How do I integrate and enable Synthetica in my application?
Make sure that the core library synthetica.jar is in your classpath. The core lib also includes the standard theme 'SyntheticaStandardLookAndFeel'.
In case that you want to you use a different theme, additionally add the theme library to your classpath. Add the lines below to your application on
application startup - in case that you want to use a different theme please take a look at the README.txt file of the downloaded theme.
try { UIManager.setLookAndFeel("de.javasoft.plaf.synthetica.SyntheticaStandardLookAndFeel"); //Another way is to use the #setLookAndFeel method of the SyntheticaLookAndFeel class //SyntheticaLookAndFeel.setLookAndFeel(String className, boolean antiAlias, boolean useScreenMenuOnMac); } catch (Exception e) { e.printStackTrace(); }
2. Why do text components ignore non-opaque settings?
In Swing/Synth you run into a paint problem when you try to provide non-rectangular components.
As long as your components are opaque (which is generally the default) the background will be
rectangulary filled by Swing with the default background color. The result is that sections
will be colorized which aren't part of the component. On light backgrounds this behaviour
doesn't matter because it's hard to recognize. However on dark backgrounds light pixel fragments
appear at the component edges (see image below).
Synthetica V2.0 and above solves this behaviour by setting the opaque property for text components
and comboBoxes to false by default. The Synthetica painter ignores the opaque settings
and will paint the background anyway. If you want to disable background painting for example for
JTextArea components used as description fields you have to provide the 'Synthetica.opaque' client property
by calling JComponent#putClientPropery() - see example below.
Synthetica V1.X: | Synthetica V2.X: |
![]() | ![]() |
myTextField.putClientPropery("Synthetica.opaque", Boolean.FALSE);With respect to existing applications there is a simple way to switch back to the traditional opaque handling by providing "Synthetica.textComponents.useSwingOpaqueness" through the UIManager:
UIManager.put("Synthetica.textComponents.useSwingOpaqueness", Boolean.TRUE);This is the simple method if you want to run your application with Synthetica V2.0 but it isn't recommended. The recommended way is to add
#putClientPropery("Synthetica.opaque", Boolean.FALSE)
to all of your components and comboBoxes where #setOpaque(false)
is required.
Enabling opacity is normally not necessary.
Conclusion:
- Textcomponents and comboBoxes are opaque by default.
- Use JComponent#putClientPropery("Synthetica.opaque", Boolean.FALSE) to disable opacity.
- Do not use a ColorUIResource as a background color.
- Traditional opaque handling can be enabled by UIManager.put("Synthetica.textComponents.useSwingOpaqueness", Boolean.TRUE); but isn't recommended.
3. Why does my app window flicker while resizing?
The flickering occurs as long as non-native window decoration is used - which is the default in Synthetica. You can enable native
window decoration but this isn't recommended because your application will look inconsistent. The cause for flickering is Bug 4967886
- also known as 'grey rect bug' which is already fixed in Java 6. So using Java 6 or above is recommended - unfortunately the fix is not part of the Mac JVM.
4. How can I enable logging to see which images being loaded?
Synthetica supports some JDK logging. To enable logging start your application with
the argument -Djava.util.logging.config.file=logging.properties.
Content of the file
Content of the file
logging.properties
:
handlers = java.util.logging.ConsoleHandler java.util.logging.ConsoleHandler.level = FINE # Turn on class-specific logging levels here de.javasoft.plaf.synthetica.painter.level = FINE com.level = INFO
5. Why switching look and feel during runtime can cause problems?
LAF Switching during runtime to non-Synthtica look and feels can cause transparent
menus and disappearing window decoration.
Synthetica paints the window decoration by itself (non-native), but other look and feels mostly
use the native window decoration of the operating system. Because Swing doesn't support changing
windows decoration from non-native to native during runtime the decoration completely disappears.
The effect can be realized when you start your application with the Metal look and feel and
JFrame#setDefaultLookAndFeelDecorated(true)
. After switching back to the System look and
feel no window decoration appears. To support switching during runtime you can configure
Synthetica to use native window decoration, but this would break your complete application
look, so it isn't recommended.
Because most look and feels do not initialize components opaque settings, menus
will become transparent by switching to another LAF. As a possible workaround
Synthetica comes along with a method which can be called before setting the new
look and feel:
import de.javasoft.plaf.synthetica.StyleFactory; ((StyleFactory)SynthLookAndFeel.getStyleFactory()).prepareMetalLAFSwitch(); UIManager.setLookAndFeel(new MetalLookAndFeel()); SwingUtilities.updateComponentTreeUI(...);Conclusion: Switching between different look and feels during runtime is only recommended for Synthetica based look and feels. If you want to support other (non-Synthetica) look and feels you should automatically restart the complete application after a LAF switch so your application works pretty perfect with every look and feel.
6. Why is my text area component opaque even if set non-opaque?
If your text component is placed in a scrollpane you also have to change the opaque setting for the scrollpane.
Also see General FAQ 2. The example below demonstrates a borderless, non-opaque textarea
which can be used as a multiline label:
JTextArea ta = new JTextArea(); ta.setText("My description"); ta.putClientProperty("Synthetica.opaque", Boolean.FALSE); ta.setOpaque(false); ta.setEditable(false); JScrollPane sp = new JScrollPane(ta); sp.putClientProperty("Synthetica.opaque", Boolean.FALSE); sp.setOpaque(false); sp.getViewport().setOpaque(false); sp.setBorder(null);
7. Why a JFrame hides the OS TaskBar when being displayed maximized via JFrame#setExtendedState()?
The described problem is a Swing issue which appears only with non-native decorated frames by using
JFrame#setExtendedState()
.
The workaround below can be used to fix the issue - whereas this
is the JFrame instance:
//set state after #setVisible to make sure maximized icon is set if (this.getRootPane().getUI() instanceof SyntheticaRootPaneUI) ((SyntheticaRootPaneUI) this.getRootPane().getUI()).setMaximizedBounds(this); this.setExtendedState(JFrame.MAXIMIZED_BOTH);
8. How to enable hiding/overlapping the OS TaskBar when a window becomes maximized?
Start your application with the argument -Dsynthetica.frame.fullscreen. The switch disables the
Synthetica workaround to avoid painting over the taskbar (see Swing Bug 4737788).
9. Why does maximizing windows in multiscreen environments on Linux fail?
Synthetica implements a workaround to avoid painting over the taskbar (see Swing Bug 4737788).
Unfortunaltely the workaround can cause maximization problems in Linux multiscreen environments. So on Linux multiscreen environments you should possibly start your application
with the argument -Dsynthetica.frame.fullscreen - see also General FAQ 8.
10. Why does the frame icon of my JInternalFrame disappear as soon as the frame is iconified?
This is a Synth bug which has been already fixed in Java 6. The workaround below can be used for Java 1.5.
JInternalFrame iFrame = new JInternalFrame(...); iFrame.setFrameIcon(...); //workaround to display frame icon also in iconified state iFrame.updateUI();
11. How can I modify the size of toolbar separators
The height for toolbar separators will be determined automatically - the default width is 1 pixel.
If you need to set the size manually this can be done with the method
SyntheticaLookAndFeel#setToolbarSeparatorDimension(Dimension dim)
.
import java.awt.Dimension; import de.javasoft.plaf.synthetica.SyntheticaLookAndFeel; import de.javasoft.plaf.synthetica.SyntheticaStandardLookAndFeel; try { UIManager.setLookAndFeel(new SyntheticaStandardLookAndFeel()); SyntheticaLookAndFeel.setToolbarSeparatorDimension(new Dimension(1,32)); } catch (Exception e) { e.printStackTrace(); }
12. How can I disable the popup menu blur effect for SyntheticaMetallic themes?
You can achieve this by setting the UI-property
Synthetica.popupMenu.blur.enabled
to false
before setting the look and feel - see example below.
UIManager.put("Synthetica.popupMenu.blur.enabled", false); UIManager.setLookAndFeel("de.javasoft.plaf.synthetica.SyntheticaSkyMetallicLookAndFeel");
13. How can I use Synthetica in an Applet or Web Start application?
Unfortunately unsigned Applets and Web Start apps are currently not supported. Please sign your applet or
Web Start application - see also
How to sign applets.
14. How can I display a frame icon and system menu for JDialogs?
By default a dialog icon does not appear if non-native window decoration is used. You can enable the icon usage by setting the
UI-property
Synthetica.dialog.icon.enabled
to true (see also customization) -
see example below.
UIManager.put("Synthetica.dialog.icon.enabled", true); UIManager.setLookAndFeel("de.javasoft.plaf.synthetica.SyntheticaSkyMetallicLookAndFeel");
15. How can I colorize a JComponent/JButton?
Since Synthetica V2.4.0 we've added support for the client properties
Synthetica.background
and Synthetica.background.alpha
.
The alpha value specifies the color opacity - lower values means less colorizing. If no alpha value is specified a default value of 0.10f
will be used - see example below.
JButton button = new JButton("Red Button"); button.putClientProperty("Synthetica.background", Color.RED); button.putClientProperty("Synthetica.background.alpha", 0.20f);
16. How can I enable the screenMenuBar support on Mac OSX?
Since Synthetica V2.7.0 there's a convenient static method
SyntheticaLookAndFeel#setLookAndFeel(String className)
which can be used instead of UIManager#setLookAndFeel(String className)
. The method enables the screenMenuBar
feature on MAC OSX 10.5 - see also General FAQ 1.
Note: The screenMenuBar feature is not supported on Mac OSX 10.4.
17. Sometimes my application isn't completely repainted - what's going wrong?
This could be caused by an exception or a deadlock. Such an issue can be caused if your application is started
from the main thread instead of the event dispatch thread (EDT). Citate from Alex from Sun:
"If you work with Swing not from EDT all sorts of strange things can happen".
There is no guarantee that your code works well even if it works in most cases. You can check your code for EDT violations
by the CheckThreadViolationRepaintManager.
The example below demonstrates how the repaint manager is used and how you poperly startup your application. Don't forget to add the
debug.jar
library from swinghelper.dev.java.net to your classpath.
UIManager.setLookAndFeel(...); //replace the repaint manager only temporary for debugging RepaintManager.setCurrentManager(new CheckThreadViolationRepaintManager()); EventQueue.invokeLater(new Runnable(){ public void run() { new MyApplication(); } });
18. How can I render my own logo in the window title panel?
Since V2.7.0 Synthetica provides a logo renderer interface which can be used for such things.
Generally the renderer area includes the window tile panel and the menu bar but for some themes only the title bar will be used.
For more details take a look into the API-Doc (SyntheticaLogoRenderer). The example below demonstrates the usage.
LogoRenderer renderer = new LogoRenderer(); renderer.setHorizontalAlignment(SwingConstants.CENTER); renderer.setText(getTitle()); renderer.setIcon(myLogo); myFrame.getRootPane().putClientProperty("Synthetica.logoRenderer", renderer); ... public class LogoRenderer extends JLabel implements SyntheticaLogoRenderer { public JComponent getRendererComponent(JRootPane root, boolean windowIsActive) { return this; } }
19. How can I disable toolBar background painting?
Even if your tool bar is set to non-opaque a background appears because we want to support translucent toolbars.
You can completely disable background painting by putting the client property
Synthetica.opaque
to the tool bar - see example below.
myToolBar.putClientProperty("Synthetica.opaque", Boolean.FALSE);
20. How can I improve drag performance for JInternalFrames?
Swing's DefaultDesktopManager provides drag optimization for opaque internal frames only. That's why non-opaque frames (with shadowed borders) won't
get optimized. Synthetica provides an optional DesktopManager with can be set to improve dragging performance especially on legacy hardware - see example below.
Please contact support if you want to enable Synthetica's DesktopManager as default desktop manager in your Look and Feel.
desktopPane.setDesktopManager(new de.javasoft.plaf.synthetica.SyntheticaDesktopManager();
21. Why is the background color for a JTabbedpane child component ignored?
In Synthetica the JTabbedPane handling is a bit special because Synthatica is able to
modify children opacity. In most cases this leads to the wanted result. However, you
can disable this feature by setting the UI-property 'Synthetica.tabbedPane.keepOpacity'
to true.
UIManager.setLookAndFeel(...); UIManager.put("Synthetica.tabbedPane.keepOpacity", true);It is also possible to leave the default value unchanged and to set a client property instead, just like below. The property 'Synthetica.tabbedPane.keepOpacity' works for a single component. The property 'Synthetica.tabbedPane.keepChildrenOpacity' affects child components only.
myTabbedPaneChild.putClientProperty("Synthetica.tabbedPane.keepOpacity", true); myTabbedPaneChild.putClientProperty("Synthetica.tabbedPane.keepChildrenOpacity",true);
22. Does Syntetica support the Java Module System JPMS?
The Java Module System (JPMS) is supported since Synthetica/SyntheticaAddons V3. For
more information about how to use take a look a the README.TXT file which is part of
each download.
23. I'm getting an IllegalAccessError or illegal reflective access warning - what's going wrong?
Java 9 (JPMS) introduces strong encapsulation to improve security. When you're running
your application on Java 9 or higher in classpath mode (legacy mode) you have to pass
the arguments below to the JVM for proper execution without any errors/warnings. For Synthetica V3
you have to use 'synthetica.base' as module name - for more information take a look at the README.TXT
which is part of each download package.
--add-exports=java.desktop/sun.swing=ALL-UNNAMED --add-exports=java.desktop/sun.swing.table=ALL-UNNAMED --add-exports=java.desktop/sun.swing.plaf.synth=ALL-UNNAMED --add-opens=java.desktop/javax.swing.plaf.synth=ALL-UNNAMED --add-opens=java.desktop/javax.swing.plaf.basic=ALL-UNNAMED --add-opens=java.desktop/javax.swing=ALL-UNNAMED --add-opens=java.desktop/javax.swing.tree=ALL-UNNAMED --add-opens=java.desktop/java.awt.event=ALL-UNNAMED --add-exports=java.desktop/sun.awt.shell=ALL-UNNAMED --add-exports=java.base/sun.security.action=ALL-UNNAMED --add-exports=java.desktop/com.sun.awt=ALL-UNNAMED // required for SyntheticaAddons only // --add-exports=java.desktop/com.sun.java.swing.plaf.windows=ALL-UNNAMEDAlternatively, you can put the arguments into the manifest.mf file of your application by adding the attributes below.
Add-Exports: java.desktop/sun.swing java.desktop/sun.swing.table java.desktop/sun.swing.plaf.synth java.desktop/com.sun.java.swing.plaf.windows java.desktop/sun.awt.shell java.desktop/com.sun.awt java.base/sun.security.action Add-Opens: java.desktop/javax.swing.plaf.synth java.desktop/javax.swing.plaf.basic java.desktop/javax.swing java.desktop/javax.swing.tree java.desktop/java.awt.event
Window Decoration
1. How can I enable native window decoration?
Synthetica's windows decoration is enabled by default. To use the OS native decoration instead, invoke
SyntheticaLookAndFeel.setWindowsDecorated(false)
.
Ensure to invoke the method before setting the Look and Feel.
import de.javasoft.plaf.synthetica.SyntheticaLookAndFeel; import de.javasoft.plaf.synthetica.SyntheticaStandardLookAndFeel; try { SyntheticaLookAndFeel.setWindowsDecorated(false); //Another way is to use the UIManager setting below //UIManager.put("Synthetica.window.decoration", false); UIManager.setLookAndFeel(new SyntheticaStandardLookAndFeel()); } catch (Exception e) { e.printStackTrace(); }
2. Synthetica's window decoration does not appear - why?
Synthetica's windows decoration is enabled by default. If your windows appear with the window decoration of the OS (native decoration)
you possibly set the look and feel after creating your frames. Please change the order and enable the look and feel before creating any frame.
3. How can I completely disable window decoration?
The example below demonstrates how to disable window decoration for dialog and frame instances.
myDialog.getRootPane().setWindowDecorationStyle(JRootPane.NONE); myFrame.getRootPane().setWindowDecorationStyle(JRootPane.NONE);
FileChooser
1. How can I disable the extended FileChooser component?
The extended FileChooser component is enabled by default. You can disable and switch to the regular FileChooser
via
SyntheticaLookAndFeel#setExtendedFileChooserEnabled(...)
.
import de.javasoft.plaf.synthetica.SyntheticaLookAndFeel; import de.javasoft.plaf.synthetica.SyntheticaStandardLookAndFeel; try { UIManager.setLookAndFeel(new SyntheticaStandardLookAndFeel()); SyntheticaLookAndFeel.setExtendedFileChooserEnabled(false); } catch (Exception e) { e.printStackTrace(); }
2. How can I configure the extended FileChooser not to remember preferences?
By default the extended FileChooser-UI stores and restores preferences like window-size and -position, last
directory and sort order. You can control this behavior via
SyntheticaLookAndFeel#setRememberFileChooserPreferences(...)
.
import de.javasoft.plaf.synthetica.SyntheticaLookAndFeel; import de.javasoft.plaf.synthetica.SyntheticaStandardLookAndFeel; try { UIManager.setLookAndFeel(new SyntheticaStandardLookAndFeel()); SyntheticaLookAndFeel.setRememberFileChooserPreferences(false); } catch (Exception e) { e.printStackTrace(); }
3. How can I improve the performance of the FileChooser?
You can disable the usage of system file icons and sorting as in the example below.
UIManager.put("Synthetica.extendedFileChooser.useSystemFileIcons", false); UIManager.put("Synthetica.extendedFileChooser.sortEnabled", false); UIManager.setLookAndFeel("de.javasoft.plaf.synthetica.SyntheticaStandardLookAndFeel");
4. Sometimes my application freeze when the FileChooser appears - what can I do?
This can be caused on Java 6 by JVM Bug 6744953
/ 6713352.
A possible workaround is to set the "rememberLastDirectory" UI-property to false - see below.
UIManager.put("Synthetica.extendedFileChooser.rememberLastDirectory", false); UIManager.setLookAndFeel("de.javasoft.plaf.synthetica.SyntheticaStandardLookAndFeel");
Font
1. How can I change the default font programmatically?
You can use
SyntheticaLookAndFeel#setFont(String fontName, int fontSize)
- see example below.
import de.javasoft.plaf.synthetica.SyntheticaLookAndFeel; import de.javasoft.plaf.synthetica.SyntheticaStandardLookAndFeel; try { UIManager.setLookAndFeel(new SyntheticaStandardLookAndFeel()); SyntheticaLookAndFeel.setFont("Dialog", 12); } catch (Exception e) { e.printStackTrace(); }
2. How can I enable font anti-aliasing?
If you want to enable anti-aliasing on Java 1.5 you can use the system property 'swing.aatext' - see example below.
With Java SE 6 this method will not work. In Java SE 6 Swing comes along with a very good subpixel anti-aliasing which
will be automatically enabled as soon as anti-aliasing of the operating system (in Windows called 'Cleartype') is enabled.
try { System.setProperty("swing.aatext", "true"); UIManager.setLookAndFeel(new SyntheticaStandardLookAndFeel()); //deprecated method //SyntheticaLookAndFeel.setAntiAliasEnabled(true); } catch (Exception e) { e.printStackTrace(); }
3. Which font is used on platforms where my configured font doesn't exist?
In case that your font or Synthetica's default font isn't available on the platform Synthetica falls back to the 'Dialog' font.
Dialog is a logical font which will be mapped to a physical font (see below). Generally in Synthetica themes 'Tahoma' is set as default font.
From the API:
Logical fonts are the five font families defined by the Java platform which must be supported by any Java runtime environment:
Serif, SansSerif, Monospaced, Dialog, and DialogInput. These logical fonts are not actual font libraries. Instead, the logical
font names are mapped to physical fonts by the Java runtime environment. The mapping is implementation and usually locale dependent,
so the look and the metrics provided by them vary. Typically, each logical font name maps to several physical fonts in order to
cover a large range of characters. See also: Text-Rendering
4. Non-Western (Chinese and Japanese) characters won't get displayed - why?
This is a font issue and not a Synthetica issue. Synthetica's default font is set to 'Tahoma' which does not contain any Chinese or Japanese characters.
The solution is to set the Default font to 'Dialog' as described in Font FAQ 1 and Customization FAQ 1
5. How can I disable Synthetica's default font for a component instance?
Create a customized look and feel (see Customization FAQ 2). The defaults property key
Synthetica.font.disabled.{componentName}
disables Synthetica's default font, so that the configured font will be applied.
JTextPane Example (Section JTextPane): <defaultsProperty key="Synthetica.font.disabled.MyTextPane" type="boolean" value="true"/>Note: The component name in the example above is "MyTextPane".
Renderer
1. How can I set my own JTable header renderer without loosing Synthetica's header style?
Sometimes you'll need a custom table header renderer e.g. for painting a sort arrow or something else.
The following example uses the original installed default header renderer and modifies the JLabel to add an icon:
final TableCellRenderer tableCellRenderer = table.getTableHeader().getDefaultRenderer(); table.getTableHeader().setDefaultRenderer(new DefaultTableCellRenderer() { public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int rowIndex, int columnIndex) { JLabel l = (JLabel)tableCellRenderer.getTableCellRendererComponent(table, value, isSelected, hasFocus, rowIndex, columnIndex); l.setIcon(arrowIcon); l.setHorizontalTextPosition(JLabel.LEADING); return l; } }Before Synthetica V2.3.0 setting a new HeaderRenderer border wasn't possible because of Issue 6469640. In this case you have to emulate the HeaderRenderer for customizations within the border (like sort arrow painting):
table.getTableHeader().setDefaultRenderer(new DefaultTableCellRenderer() { public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int rowIndex, int columnIndex) { //create a new HeaderRenderer JLabel l = new JLabel(value.toString()); l.setFont(table.getTableHeader().getFont()); l.setForeground(table.getTableHeader().getForeground()); l.setBorder(new CompoundBorder(new MatteBorder(0, 0, 0, 1, UIManager.getColor( "Synthetica.tableHeader.gridColor")), l.getBorder())); l.setIcon(arrowIcon); l.setHorizontalTextPosition(JLabel.LEADING); return l; } }Since Synthetica V2.3.0 the Synth HeaderRenderer is replaced by Synthetica, so you can simply apply a user-defined border to the default HeaderRenderer.
2. Why is the selection color of my customized TableCellRenderer ignored?
If your CellRenderer makes use of a text-component like JTextArea you have to be aware of General FAQ 2.
In most cases the issue can be simply resolved by replacing the selection color (which is generally an instance
of ColorUIResource) with a normal Color instance - see eaxample below.
table.setSelectionBackground(new Color(table.getSelectionBackground().getRGB()));
Customization
1. How can I customize an existing Synthetica Look and Feel?
Each Synthetica theme contains a file called 'synth.xml'. One possibility for customizing is to extract the jar library
and modify the xml file. The disadvantage of this solutions is that you have to do this each time a LAF is updated or if a
new theme becomes available. Another way is to define an external XML file called 'Synthetica.xml' or {LAF-Name}.xml for instance
'SyntheticaBlueIceLookAndFeel.xml'. Where 'Synthetica.xml' contains common settings used for all Synthetica themes and
the {LAF-Name}.xml contains only settings for the specified LAF (theme). In case of defining values in both files the
{LAF-Name}.xml has priority to 'Synthetica.xml'.
Don't forget to add the XML-file(s) to your classpath. The following example is used to set the default font to antialiased
'Dialog 14 Bold' for all Synthetica themes.
<!-- synthetica.xml --> <synth> <style id="default"> <state> <font id="SyntheticaDefaultFont" name="Dialog" size="14" style="BOLD"/> </state> <defaultsProperty key="Synthetica.text.antialias" type="boolean" value="true"/> </style> <bind style="default" type="region" key=".*" /> <style id="panel"> <state> <opaque value="true"/> </state> </style> <bind style="panel" type="region" key="Panel"/> </synth>Since Synthetica V2.12.0 the customization method above is deprecated and disabled by default. However, you can set the system property 'synthetica.enhancedXMLLookup' to enable lookup for additional XML-files. The recommended way for loading an additional XML-file since V2.12.1 is to override SyntheticaLookAndFeel#loadCustomXML().
//since V2.12.1 UIManager.setLookAndFeel(new SyntheticaStandardLookAndFeel(){ @Override protected void loadCustomXML() throws ParseException { loadXMLConfig("/com/company/custom.xml"); } });Another way is to override SyntheticaLookAndFeel#loadXMLConfig() - but this is no longer recommended since #loadCustomXML() is available.
UIManager.setLookAndFeel(new SyntheticaStandardLookAndFeel(){ @Override protected void loadXMLConfig(String fileName) throws ParseException { super.loadXMLConfig(fileName); super.loadXMLConfig("/com/company/myCustomSynth.xml"); } });
2. How can I create a custom style and apply it to a component instance?
Support for mixed component styles is available since Synthetica V2.1.0.
- Take a look at Javalobby - Customize Synthetica Look and Feel for general customization.
- Copy a style section within the synth.xml file to create an additional style and change the binding type to "name" whereas the key represents your component name.
JButton Example: <!-- *********************************************** Button *********************************************** --> <style id="button"> ... </style> <bind style="button" type="region" key="Button"/> <!-- *********************************************** Additional customized button style. *********************************************** --> <style id="mybutton"> ... </style> <bind style="mybutton" type="name" key="MyButton"/>
- Append the components name to each defaultsProperty key within this section - this is what we call "named defaults properties".
JButton Example: <style id="mybutton"> <property key="Button.textShiftOffset" type="integer" value="1"/> <state> <insets top="4" left="4" bottom="4" right="4"/> <property key="Button.margin" type="insets" value="0 10 0 10"/> <defaultsProperty key="Synthetica.button.border.insets.MyButton" type="insets" value="4 4 4 4"/> <defaultsProperty key="Synthetica.button.12x12.border.insets.MyButton" type="insets" value="3 3 3 3"/> ... </style> <bind style="mybutton" type="name" key="MyButton"/>
- Ready to go - use
JButton#setName("MyButton")
to set the component name. All buttons named "MyButton" should now appear with your new defined style ("mybutton").
3. How can I create mixed styles for a JTabbedPane?
Because a JTabbedPane contains subregions (TabbedPaneContent, TabbedPaneTabArea, TabbedPaneTab) you'll have to
use a special syntax to address these subregions. The prefix of the key is the name of the subregion.
Example: <style id="myTabbedPane"> ... </style> <bind style="myTabbedPane" type="name" key="MyTabbedPane"/> <style id="myTabbedPaneContent"> ... </style> <bind style="myTabbedPaneContent" type="name" key="TabbedPaneContent.MyTabbedPane"/> <style id="myTabbedPaneTabArea"> ... </style> <bind style="myTabbedPaneTabArea" type="name" key="TabbedPaneTabArea.MyTabbedPane"/> <style id="myTabbedPaneTab"> <insets top="2" left="10" bottom="14" right="10"/> <defaultsProperty key="Synthetica.tabbedPane.tab.selected.bold.MyTabbedPane" type="boolean" value="true"/> ... </style> <bind style="myTabbedPaneTab" type="name" key="TabbedPaneTab.MyTabbedPane"/>
4. How can I add an additional style for a JTabbedPane?
5. The configured background image for text components doesn't appear - what's wrong?
This feature is supported since Synthetica V2.2.0. For customization you can enable the use of background images with the entries below.
<defaultsProperty key="Synthetica.{component}.border.opaqueBackground" type="boolean" value="true"/> <defaultsProperty key="Synthetica.{component}.border.disabled.opaqueBackground" type="boolean" value="true"/>Valid values for
component
are "textField", "formattedTextField", "passwordField, "textArea", "textPane",
"editorPane", "comboBox" and "spinner". See also customization.
6. How can I rename arrow buttons for customization?
If you want to apply a special style (see Customization FAQ 2.) for arrow buttons you run into troubles
because arrow buttons are child components of other components like JScrollPane, JComboBox and JSpinner - they can not be named directly.
However Synthetica V2.2.0 comes along with a convenient static method (
Default name of arrow button for JComboBox: "ComboBox.arrowButton"
Default name of arrow button for JSpinner: "Spinner.previousButton", "Spinner.nextButton"
Example for renaming the arrow buttons of a JScrollPane:
SyntheticaLookAndFeel#setChildrenName()
) to modify the name
of child components. Most component children already have default names which can be used for addressing and renaming.
Default name of arrow button for JScrollPane: "ScrollBar.button"Default name of arrow button for JComboBox: "ComboBox.arrowButton"
Default name of arrow button for JSpinner: "Spinner.previousButton", "Spinner.nextButton"
Example for renaming the arrow buttons of a JScrollPane:
JScrollPane scrollPane = new JScrollPane(); SyntheticaLookAndFeel.setChildrenName(scrollPane, "ScrollBar.button", "MyArrowButton");