Finds an AWT or Swing {@code Component} by name. If this finder is attached to a {@link Robot}, it will use the component lookup scope in the {@code Robot}'s {@link Settings} to determine whether the component to find should beshowing or not. If this finder is not attached to any {@code Robot}, the component to find does not have to be showing.
Let's assume we have the {@code JTextField} with name "myTextBox";
JTextField textbox = new JTextField(); textBox.setName("myTextBox");
To get a reference to this {@code JTextField} by its name, we can specify:
JTextField textBox = (JTextField) finder.findByName("myTextBox");
Please note that you need to cast the result of the lookup to the right type. To avoid casting, please use one of following:
- {@link #findByName(String,Class)}
- {@link #findByName(String,Class,boolean)}
- {@link #findByName(Container,String,Class)}
- {@link #findByName(Container,String,Class,boolean)}
@param name the name of the component to find.
@return the found component.
@throws ComponentLookupException if a matching component could not be found.
@throws ComponentLookupException if more than one matching component is found.
@see Robot#settings()
@see Settings#componentLookupScope()
@see ComponentLookupScope