import javax.swing.*; import java.beans.BeanDescriptor; import java.beans.BeanInfo; import java.beans.IntrospectionException; import java.beans.Introspector; import java.util.Optional; public class Test { public static void main(String[] args){ try { // Returns: the name of the getter method in the annotated class, which returns the corresponding Swing container, BeanInfo info1 = Introspector.getBeanInfo(D.class); BeanDescriptor bd1 = info1.getBeanDescriptor(); Optional.ofNullable(bd1.getValue("containerDelegate")).ifPresent(System.out::print); //or an empty string if the method name is not set. BeanInfo info2 = Introspector.getBeanInfo(T.class); BeanDescriptor bd2 = info2.getBeanDescriptor(); Optional.ofNullable(bd2.getValue("containerDelegate")).ifPresent(System.out::print); // null instead of empty string } catch (IntrospectionException e) { e.printStackTrace(); } } } @SwingContainer() class T { } @SwingContainer(delegate = "method") class D { }