What is java.awt.Component.getName()
used for? It always seems to be null
in the applications I build with NetBeans. I'm thinking of storing some help text per component in it -- I don't want to use the tooltip, I have another panel where I'll show the help text.
Java AWT (Abstract Window Toolkit) is an API to develop GUI or window-based applications in java. Java AWT components are platform-dependent i.e. components are displayed according to the view of operating system. AWT is heavyweight i.e. its components are using the resources of OS.
@Component is an annotation that allows Spring to automatically detect our custom beans. In other words, without having to write any explicit code, Spring will: Scan our application for classes annotated with @Component. Instantiate them and inject any specified dependencies into them.
It is a container that holds components like buttons, textfield, etc. Creating an instance is the way to create a Panel Container and can add components. Frame: The Frame is a container used while creating an AWT application. It can have components like title bar, menu bars, borders and also buttons, scroll bar, etc.
Java Swing is implemented entirely in the Java programming language. First of all, by a heavy-weight, it means the code will take comparatively more time to load and it will consume more System resources. AWT is considered to be heavy-weight because its components are dependent on the underlying Operating System.
Component.setName(..) is used in the JDK mostly by the look and feel implementation classes to set ID-like strings for each component, e.g. BasicOptionPaneUI might call it on a button component to set its name to "OptionPane.button".
The getName() is used in toString() methods, when setting the names of child components inside a Composite/parent Component and in AWT and Swing debug logging code. I suspect strongly that the getName() method is also used by some AWT/Swing testing frameworks.
So if you're not dependent on any of the above uses of getName(), you might try using it for your help messages, though I would not recommend it.
Maybe you should reconsider your design? Use the name to do some lookup in a hashmap that loads the help text from a resource bundle?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With