简体   繁体   中英

java list of jframe components

Hello Im working with jframe (in java) and I wonder if there is some sort of list for all the jframe Components.

What I mean with Components: jbutton, jtextarea, jcombobox and stuff like that

You can use JFrame#getComponents that is inherited from Container

Gets all the components in this container.

Note: This method should be called under AWT tree lock. Returns: an array of all the components in this container. See also: Component.getTreeLock()

Example

Component[] frameCompos = myFrame.getComponents();
// How to print it?
// 1
for (Component c : frameCompos) {
    System.out.println(c);
}
// 2
System.out.println(Arrays.toString(frameCompos));

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM