Class FrameMatcher

All Implemented Interfaces:
ComponentMatcher, ResettableComponentMatcher

public final class FrameMatcher extends NamedComponentMatcherTemplate<Frame>
Understands matching a Frame by type, name or title.
  • Field Details

    • title

      private Object title
  • Constructor Details

    • FrameMatcher

      private FrameMatcher(Object name, Object title)
  • Method Details

    • withName

      public static FrameMatcher withName(String name)
      Creates a new FrameMatcher that matches a Frame that:
      1. has a matching name
      2. (optionally) has matching title
      3. (optionally) is showing on the screen
      4. The following code listing shows how to match a Frame by name and title:

         FrameMatcher m = withName("myApp").andTitle("My App");
         

        The following code listing shows how to match a Frame, that should be showing on the screen, by name and title:

         FrameMatcher m = withName("myApp").andTitle("My App").andShowing();
         

      Parameters:
      name - the id to match.
      Returns:
      the created matcher.
    • withTitle

      public static FrameMatcher withTitle(String title)
      Creates a new FrameMatcher that matches a Frame by its title.

      The following code listing shows how to match a Frame by title:

       FrameMatcher m = withTitle("My App");
       

      The following code listing shows how to match a Frame, that should be showing on the screen, by title:

       FrameMatcher m = withTitle("My App").andShowing();
       

      Parameters:
      title - the title to match. It can be a regular expression.
      Returns:
      the created matcher.
    • withTitle

      public static FrameMatcher withTitle(Pattern titlePattern)
      Creates a new FrameMatcher that matches a Frame by its title.

      The following code listing shows how to match a Frame by title, using a regular expression matcher:

       FrameMatcher m = withTitle(Pattern.compile("My.*"));
       

      The following code listing shows how to match a Frame, that should be showing on the screen, by title:

       FrameMatcher m = withTitle(Pattern.compile("My.*")).andShowing();
       

      Parameters:
      titlePattern - the title to match.
      Returns:
      the created matcher.
      Since:
      1.2
    • any

      public static FrameMatcher any()
      Creates a new FrameMatcher that matches any Frame.
      Returns:
      the created matcher.
    • andTitle

      public FrameMatcher andTitle(String newTitle)
      Specifies the title to match. If this matcher was created using withTitle(String) or withTitle(Pattern), this method will simply update the title to match.
      Parameters:
      newTitle - the new title to match. It can be a regular expression.
      Returns:
      this matcher.
    • andTitle

      public FrameMatcher andTitle(Pattern titlePattern)
      Specifies the title to match. If this matcher was created using withTitle(String) or withTitle(Pattern), this method will simply update the title to match.
      Parameters:
      titlePattern - the regular expression pattern to match.
      Returns:
      this matcher.
      Since:
      1.2
    • andShowing

      public FrameMatcher andShowing()
      Indicates that the Frame to match should be showing on the screen.
      Returns:
      this matcher.
    • isMatching

      @RunsInCurrentThread protected boolean isMatching(Frame frame)
      Indicates whether the title of the given Frame is equal to the title in this matcher.

      Note: This method is not executed in the event dispatch thread (EDT.) Clients are responsible for invoking this method in the EDT.

      Specified by:
      isMatching in class GenericTypeMatcher<Frame>
      Parameters:
      frame - the Frame to match.
      Returns:
      true if the title in the Frame is equal to the title in this matcher, false otherwise.
    • toString

      public String toString()
      Overrides:
      toString in class Object