获取所有Swing组件在一个容器 [英] Get all swing components in a container
本文介绍了获取所有Swing组件在一个容器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想我们可以使用 jScrollPane.getComponents()
来获得JScrollPane中的AWT组件。
我的问题是:有没有办法让一个容器的Swing组件一些如何
I think we can use jScrollPane.getComponents()
to get awt components of a jscrollpane.
My question is: is there a way to get swing components of a container some how?
推荐答案
所有Swing组件扩展JComponent的。
All Swing components extend JComponent.
Component[] comps = jScrollPane.getComponents();
ArrayList<JComponent> swingComps = new ArrayList<JComponent>();
for(Component comp : comps) {
if(comp instanceof JComponent) {
swingComps.add((JComponent) comp);
}
}
这篇关于获取所有Swing组件在一个容器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文