1 23 24 29 30 package com.sun.enterprise.tools.common; 31 32 import com.sun.enterprise.tools.common.util.diagnostics.Reporter; 33 38 public class BooleanStringItemListener implements java.awt.event.ItemListener { 39 40 Object target = null; 41 java.lang.reflect.Method writer = null; 42 43 private Object args[] = { target }; 44 45 46 47 public BooleanStringItemListener(Object target, String destName) throws java.beans.IntrospectionException { 48 this.target = target; 49 writer = PropertyUtils.getWriter(target,destName); 50 } 51 52 public BooleanStringItemListener(Object target) { 53 this.target = target; 54 } 55 56 private static final String FALSE[] = {"false" }; private static final String TRUE[] = { "true" }; 59 public void itemStateChanged(java.awt.event.ItemEvent itemEvent) { 60 try { 61 java.lang.reflect.Method lwriter = writer; 62 if (null == lwriter) { 63 java.awt.Component src = (java.awt.Component ) itemEvent.getSource(); 64 lwriter = PropertyUtils.getWriter(target, src.getName()); 65 } 66 Object args[] = FALSE; 67 if (itemEvent.getStateChange() == java.awt.event.ItemEvent.SELECTED) 68 args = TRUE; 69 lwriter.invoke(target, args); 70 } 71 catch (Throwable t) { 72 Reporter.critical(t); } 74 } 75 76 } 77 | Popular Tags |