Package swingtree.api

Interface Peeker<C>

Type Parameters:
C - The component type which should be modified.

public interface Peeker<C>
Applies an action to the current component typically as part of UIForAnySwing through method UIForAnything.peek(Peeker) with the purpose of expose the underlying component to the user while preserving a declarative method chaining based builder API usage pattern.

Consider the following example of a JProgressBar in a JPanel:


        UI.panel("fill")
        .add("span, grow, wrap",
             progressBar(UI.Align.HORIZONTAL, 0, 100)
             .withValue(68)
             .peek( it -> {
                 it.setString("%");
                 it.setStringPainted(true);
             })
             .withBackground(Color.WHITE)
        )
 	
Here you can see that we can use the Peeker implementation to access the underlying JProgressBar component and set its string and string painted properties while still using the declarative method chaining based builder API.

Also consider taking a look at the living swing-tree documentation where you can browse a large collection of examples demonstrating how to use the API of Swing-Tree in general.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    accept(C component)
    Applies an action to the current component.
  • Method Details

    • accept

      void accept(C component) throws Exception
      Applies an action to the current component.
      Note that this method deliberately requires the handling of checked exceptions at its invocation sites because there may be any number of implementations hiding behind this interface and so it is unwise to assume that all of them will be able to execute gracefully without throwing exceptions.
      Parameters:
      component - The component to be modified.
      Throws:
      Exception