1 32 33 package com.nqadmin.swingSet; 34 35 import java.awt.*; 36 import javax.swing.*; 37 38 61 public class SSDBNavImp extends SSDBNavAdapter { 62 63 66 protected Container container = null; 67 68 71 public SSDBNavImp(Container _container) { 72 container = _container; 73 } 74 75 78 public void performPreInsertOps() { 79 80 setComponents(container); 81 82 } 84 93 protected void setComponents(Container _container) { 94 95 Component[] comps = _container.getComponents(); 96 97 for (int i=0; i< comps.length; i++ ) { 98 if (comps[i] instanceof JTextField) { 99 ((JTextField)comps[i]).setText(""); 101 } else if(comps[i] instanceof JTextArea) { 102 ((JTextArea)comps[i]).setText(""); 104 } else if (comps[i] instanceof JComboBox) { 105 ((JComboBox)comps[i]).setSelectedIndex(-1); 107 } else if(comps[i] instanceof SSImage) { 108 ((SSImage)comps[i]).clearImage(); 110 } else if(comps[i] instanceof JCheckBox) { 111 ((JCheckBox)comps[i]).setSelected(false); 113 } else if(comps[i] instanceof SSLabel) { 114 ((SSLabel)comps[i]).setText(""); 116 } else if(comps[i] instanceof JSlider) { 117 ((JSlider)comps[i]).setValue((((JSlider)comps[i]).getMinimum() + ((JSlider)comps[i]).getMaximum()) / 2); 119 } else if(comps[i] instanceof JPanel) { 120 setComponents((Container)comps[i]); 122 } else if(comps[i] instanceof JTabbedPane) { 123 setComponents((Container)comps[i]); 125 } else if(comps[i] instanceof JScrollPane) { 126 setComponents((Container) ((JScrollPane)comps[i]).getViewport()); 128 } 129 } 130 131 } 133 } 135 136 137 | Popular Tags |