All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.objogate.wl.swing.matcher.ButtonTextMatcher Maven / Gradle / Ivy

The newest version!
package com.objogate.wl.swing.matcher;

import javax.swing.JButton;
import org.hamcrest.Description;
import org.hamcrest.TypeSafeMatcher;

public class ButtonTextMatcher extends TypeSafeMatcher {
    private final String expectedText;

    public ButtonTextMatcher(String expectedText) {
        this.expectedText = expectedText;
    }

    @Override
    public boolean matchesSafely(JButton jButton) {
        // Note that getText can seem to return null
        return expectedText.equals(jButton.getText());
    }

    public void describeTo(Description description) {
        description.appendText("JButton with text '").appendText(expectedText).appendText("'");
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy