Substance client properties

View all API methods.

View all client properties.


Client property name

SubstanceLookAndFeel.WATERMARK_IGNORE

Description

Client property name for requesting that watermark should not be painted on the component and its descendants. This property can be set either as client property on some component or as global property on UIManager. The value should be either Boolean.TRUE or Boolean.FALSE.

In order to compute whether the current watermark should be painted on some component, the component's hierarchy is traversed bottom up. The first component that has this property set, defines the watermark visibility. Finally, if neither component not its ancestors define this property, the global setting on UIManager is checked. If there is no global setting, the watermark is not ignored (it is painted).


See also


Sample code

import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.*;

import org.jvnet.substance.SubstanceLookAndFeel;
import org.jvnet.substance.watermark.SubstanceBinaryWatermark;

/**
 * Test application that shows the use of the
 {@link SubstanceLookAndFeel#WATERMARK_IGNORE} client property.
 
 @author Kirill Grouchnikov
 @see SubstanceLookAndFeel#WATERMARK_IGNORE
 */
public class WatermarkIgnore extends JFrame {
  /**
   * Creates the main frame for <code>this</code> sample.
   */
  public WatermarkIgnore() {
    super("Watermark ignoring");

    this.setLayout(new BorderLayout());

    // create two panels with custom background colors
    final JPanel leftPanel = new JPanel();
    leftPanel.setBackground(new Color(100100180));
    JPanel rightPanel = new JPanel();
    rightPanel.setBackground(new Color(100250100));

    JPanel mainPanel = new JPanel(new GridLayout(12));
    mainPanel.add(leftPanel);
    mainPanel.add(rightPanel);

    this.add(mainPanel, BorderLayout.CENTER);

    JPanel controls = new JPanel(new FlowLayout(FlowLayout.RIGHT));
    final JCheckBox isIgnore = new JCheckBox("watermark ignore on left");
    isIgnore.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent e) {
        SwingUtilities.invokeLater(new Runnable() {
          public void run() {
            // based on checkbox selection, mark the left panel
            // to not have watermark painted
            leftPanel.putClientProperty(
                SubstanceLookAndFeel.WATERMARK_IGNORE, isIgnore
                    .isSelected() ? Boolean.TRUE : null);
            repaint();
          }
        });
      }
    });
    controls.add(isIgnore);
    this.add(controls, BorderLayout.SOUTH);

    this.setSize(400200);
    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[] argsthrows Exception {
    UIManager.setLookAndFeel(new SubstanceLookAndFeel());
    // set custom watermark
    SubstanceLookAndFeel
        .setCurrentWatermark(new SubstanceBinaryWatermark());
    JFrame.setDefaultLookAndFeelDecorated(true);
    SwingUtilities.invokeLater(new Runnable() {
      public void run() {
        new WatermarkIgnore().setVisible(true);
      }
    });
  }
}

The screenshot below shows application frame with watermark on all panels - this property is not specified:

The screenshot below shows application frame with watermark not painted on the left panel - this property is set to Boolean.TRUE: