Java tutorial
//package com.java2s; /* * Copyright (C) 2011 Peransin Nicolas. * Use is subject to license terms. */ import javax.swing.JPanel; public class Main { public static void setJPanelOpaque(JPanel p, boolean opaque) { p.setOpaque(opaque); for (int iComp = 0; iComp < p.getComponentCount(); iComp++) { if (p.getComponent(iComp) instanceof JPanel) { setJPanelOpaque((JPanel) p.getComponent(iComp), opaque); } } } }