01: package com.xoetrope.carousel.wizard;
02:
03: import java.awt.Component;
04: import java.awt.Container;
05: import javax.swing.JPanel;
06: import javax.swing.JScrollPane;
07:
08: /**
09: *
10: * <p> Copyright (c) Xoetrope Ltd., 2001-2006, This software is licensed under
11: * the GNU Public License (GPL), please see license.txt for more details. If
12: * you make commercial use of this software you must purchase a commercial
13: * license from Xoetrope.</p>
14: * <p> $Revision: 1.2 $</p>
15: */
16: public class XWizardPanel extends JPanel {
17: public XWizardPanel() {
18: }
19:
20: public XWizardPanel(String name) {
21: setName(name);
22: }
23:
24: public void updatePanel() {
25: }
26:
27: public void setEnabled(boolean state) {
28: int count = getComponentCount();
29: for (int i = 0; i < count; i++) {
30: try {
31: Component c = getComponent(i);
32: if (c instanceof javax.swing.JPanel) {
33: int ccount = ((Container) c).getComponentCount();
34: for (int j = 0; j < ccount; j++) {
35: Component cc = ((Container) c).getComponent(j);
36: cc.setEnabled(state);
37: }
38: } else if (c instanceof javax.swing.JScrollPane) {
39: int ccount = ((Container) ((JScrollPane) c)
40: .getViewport()).getComponentCount();
41: for (int j = 0; j < ccount; j++) {
42: Component cc = ((Container) ((JScrollPane) c)
43: .getViewport()).getComponent(j);
44: cc.setEnabled(state);
45: }
46: }
47: c.setEnabled(state);
48: } catch (Exception e) {
49: }
50: }
51: }
52:
53: public void setEnabled(String itemName, boolean state) {
54: int count = getComponentCount();
55: for (int i = 0; i < count; i++) {
56: try {
57: Component c = getComponent(i);
58: if (c instanceof javax.swing.JPanel) {
59: int ccount = ((Container) c).getComponentCount();
60: for (int j = 0; j < ccount; j++) {
61: Component cc = ((Container) c).getComponent(j);
62: String ccName = cc.getName();
63: if ((ccName != null)
64: && (ccName.compareTo(itemName) == 0)) {
65: cc.setEnabled(state);
66: break;
67: }
68: }
69: } else if (c instanceof javax.swing.JScrollPane) {
70: int ccount = ((Container) ((JScrollPane) c)
71: .getViewport()).getComponentCount();
72: for (int j = 0; j < ccount; j++) {
73: Component cc = ((Container) ((JScrollPane) c)
74: .getViewport()).getComponent(j);
75: String ccName = cc.getName();
76: if ((ccName != null)
77: && (ccName.compareTo(itemName) == 0)) {
78: cc.setEnabled(state);
79: break;
80: }
81: }
82: }
83:
84: String cName = c.getName();
85: if ((cName.length() > 0)
86: && (cName.compareTo(itemName) == 0)) {
87: c.setEnabled(state);
88: break;
89: }
90: } catch (Exception e) {
91: }
92: }
93: }
94: }
|