# Substance API

View all API methods.

View all client properties.

API method | `public static void setDecorationType(JComponent comp, DecorationAreaType type)`

Description | Sets the decoration type of the specified component and all its children. Parameters:

- `comp` - Component.
- `type` - Decoration type of the component and all its children.

See also |

- getDecorationType(Component) API.

Sample code | `import java.awt.BorderLayout; import java.awt.FlowLayout; import javax.swing.*; import org.jvnet.substance.SubstanceLookAndFeel; import org.jvnet.substance.painter.decoration.DecorationAreaType;
import org.jvnet.substance.skin.SubstanceBusinessBlackSteelLookAndFeel;
/**
* Test application that shows the use of the
* {@link SubstanceLookAndFeel#setDecorationType(JComponent, org.jvnet.substance.painter.decoration.DecorationAreaType)}
* API.
*
* @author Kirill Grouchnikov
* @see SubstanceLookAndFeel#setDecorationType(JComponent, org.jvnet.substance.painter.decoration.DecorationAreaType)
*/
public class SetDecorationType extends JFrame {
/**
* Creates the main frame for <code>this</code> sample.
*/
public SetDecorationType() {
super("Set decoration type");
this.setLayout(new BorderLayout());
JPanel controls = new JPanel(new FlowLayout(FlowLayout.RIGHT));
SubstanceLookAndFeel.setDecorationType(controls, DecorationAreaType.GENERAL);
JToggleButton controlButton = new JToggleButton("control");
controlButton.setSelected(true);
JCheckBox controlCheckBox = new JCheckBox("control");
controlCheckBox.setSelected(true);
controls.add(new JLabel("GENERAL decoration:"));
controls.add(controlButton);
controls.add(controlCheckBox);
this.add(controls, BorderLayout.SOUTH);
JPanel content = new JPanel(new FlowLayout());
JToggleButton sampleButton = new JToggleButton("control");
sampleButton.setSelected(true);
JCheckBox sampleCheckBox = new JCheckBox("control");
sampleCheckBox.setSelected(true);
content.add(new JLabel("Default decoration:"));
content.add(sampleButton);
content.add(sampleCheckBox);
this.add(content, BorderLayout.CENTER);
this.setSize(400, 200);
this.setLocationRelativeTo(null);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
/**
* The main method for <code>this</code> sample. The arguments are
* ignored.
*
* @param args
* Ignored.
* @throws Exception
* If some exception occured. Note that there is no special
* treatment of exception conditions in <code>this</code>
* sample code.
*/
public static void main(String[] args) throws Exception {
UIManager.setLookAndFeel(new SubstanceBusinessBlackSteelLookAndFeel());
JFrame.setDefaultLookAndFeelDecorated(true);
JDialog.setDefaultLookAndFeelDecorated(true);
SwingUtilities.invokeLater(new Runnable() {
public void run() {
new SetDecorationType().setVisible(true);
}
});
}
}`

The screenshot below shows application frame with two panels. The bottom panel has the decoration type set to `DecorationAreaType.GENERAL`. Note how the controls in this panel are painted with a different color scheme:

To decide on the decoration area type of the specific component, the runtime looks at the component itself and all its ancestors. The first occurence of a component marked with this API defines the decoration area type. Potentially, you can have a container that is marked with one decoration area type, but one of its children is marked with another.

Here is a sample test application that marks a tabbed pane to be `DecorationAreaType.HEADER` and all the tabs to be `DecorationAreaType.NONE`. The visual result is a continuous appearance of the top tab area, with all the tab controls using the default color schemes.

`import java.awt.BorderLayout;
import java.awt.FlowLayout;
import javax.swing.*;
import org.jvnet.substance.SubstanceLookAndFeel;
import org.jvnet.substance.painter.decoration.DecorationAreaType;
import org.jvnet.substance.skin.SubstanceBusinessBlueSteelLookAndFeel;
/**
* Test application that shows the use of the {@link
* SubstanceLookAndFeel#setDecorationType(JComponent, DecorationAreaType)} API
* called on different components.
*
* @author Kirill Grouchnikov
* @see SubstanceLookAndFeel#setDecorationType(JComponent, DecorationAreaType)
*/
public class SetDecorationTypeMix extends JFrame {
/**
* Creates the main frame for <code>this</code> sample.
*/
public SetDecorationTypeMix() {
super("Mix decoration types");
this.setLayout(new BorderLayout());
JTabbedPane tabs = new JTabbedPane();
SubstanceLookAndFeel.setDecorationType(tabs, DecorationAreaType.HEADER);
JPanel tab1 = new JPanel(new FlowLayout());
tab1.add(new JTextField("sample"));
tab1.add(new JComboBox(new Object[] { "sample" }));
SubstanceLookAndFeel.setDecorationType(tab1, DecorationAreaType.NONE);
JPanel tab2 = new JPanel(new FlowLayout());
tab2.add(new JTextField("sample2"));
tab2.add(new JComboBox(new Object[] { "sample2" }));
SubstanceLookAndFeel.setDecorationType(tab2, DecorationAreaType.NONE);
tabs.addTab("tab1", tab1);
tabs.addTab("tab2", tab2);
this.add(tabs, BorderLayout.CENTER);
this.setSize(400, 200);
this.setLocationRelativeTo(null);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
/**
* The main method for <code>this</code> sample. The arguments are ignored.
*
* @param args
* Ignored.
* @throws Exception
* If some exception occured. Note that there is no special
* treatment of exception conditions in <code>this</code> sample
* code.
*/
public static void main(String[] args) throws Exception {
UIManager.setLookAndFeel(new SubstanceBusinessBlueSteelLookAndFeel());
JFrame.setDefaultLookAndFeelDecorated(true);
JDialog.setDefaultLookAndFeelDecorated(true);
SwingUtilities.invokeLater(new Runnable() {
public void run() {
new SetDecorationTypeMix().setVisible(true);
}
});
}
}`

The screenshot below shows this frame. Note the visual appearance of the tab area and the controls in the selected tab: