我有一些兒童Swing組件。當我父母上的我setOpaque(false)
,孩子仍然有不透明。Java Swing - 爲所有兒童組件設置不透明度?
所以我砍死了這個功能(感謝SOF用戶):
Component[] comps = this.getComponents();
for(Component c : comps) { if(c instanceof JComponent) {
((JComponent)c).setOpaque(false); }
}
但現在我與自我懷疑所困擾 - 這似乎有點笨重,有沒有更好的辦法做到這一點?
將'this'' ContainerListener'添加到剛剛添加的子項中怎麼樣? – Mohayemin