Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide tooling to work with 3rd party libraries where the components are not named #256

Open
beirtipol opened this issue Dec 9, 2020 · 1 comment

Comments

@beirtipol
Copy link

beirtipol commented Dec 9, 2020

I work a lot with 3rd party software where the UI has not been well designed and components generally do not have a 'name' attribute set, and that makes the matching code quite verbose, or sometimes impossible and I have to resort to reflection to access the components.

I've raised a PR #255 which addresses this by providing a mechanism to set the name of components. It works as follows:

Use the field name where possible. e.g.

private JTextField myText; // Set the name to be 'myText'

For anonymous fields, use a unique generated name. e.g.

public void createComponents(){
  add(new JTextField()); // Set the name to be 'JTextField-1'
  add(new JTextField()); // Set the name to be 'JTextField-2'
}

Optionally allow overwriting the names of fields. This is useful where the components have been given unsuitable or identical names.

public void createComponentsBadly(){
  textField1.setName("text1");
  ...
  textField2.setName("text1");
}

Optionally allow only using generated names. This is useful when the code has been obfuscated and the field names do not provide any meaning, or when the field names are confusing

private JTextField a; // Set the name to be 'JTextField-1'
private JTextField b; // Set the name to be 'JTextField-2'
private JTextField combo1; // Set the name to be 'JTextField-3'
@beirtipol
Copy link
Author

Any way to get some attention on this one?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant