From 715750c05513d5b51d23b1c1d75f5513b2d0d7e6 Mon Sep 17 00:00:00 2001 From: ray Date: Mon, 12 Jan 2004 08:39:49 +0000 Subject: [PATCH] added setOpaque(). git-svn-id: https://samskivert.googlecode.com/svn/trunk@1367 6335cc39-0255-0410-8fd6-9bcaacd3b74c --- .../com/samskivert/swing/util/SwingUtil.java | 20 ++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/projects/samskivert/src/java/com/samskivert/swing/util/SwingUtil.java b/projects/samskivert/src/java/com/samskivert/swing/util/SwingUtil.java index fbd9104c..4acb0cb2 100644 --- a/projects/samskivert/src/java/com/samskivert/swing/util/SwingUtil.java +++ b/projects/samskivert/src/java/com/samskivert/swing/util/SwingUtil.java @@ -1,5 +1,5 @@ // -// $Id: SwingUtil.java,v 1.28 2003/12/19 04:07:33 mdb Exp $ +// $Id: SwingUtil.java,v 1.29 2004/01/12 08:39:49 ray Exp $ // // samskivert library - useful routines for java programs // Copyright (C) 2001 Michael Bayne @@ -246,13 +246,27 @@ public class SwingUtil public static void setEnabled (Container comp, final boolean enabled) { applyToHierarchy(comp, new ComponentOp() { - public void apply (Component comp) - { + public void apply (Component comp) { comp.setEnabled(enabled); } }); } + /** + * Set the opacity on the specified component, and all of its + * children. + */ + public static void setOpaque (JComponent comp, final boolean opaque) + { + applyToHierarchy(comp, new ComponentOp() { + public void apply (Component comp) { + if (comp instanceof JComponent) { + ((JComponent) comp).setOpaque(opaque); + } + } + }); + } + /** * Apply the specified ComponentOp to the supplied component * and then all its descendants.