툴작업중 내 서브프레임들 (dbinfo, ddl, dml, dql, console만 빼고) 각각이 사용자가 입력한 문자열들을 save/load 지원을 
해줘서 xml파일로 관리하기로 마음먹고.. 지난번에 작업해둔.. property.loadFromXml인가를 사용하려 하다가.. 

propertyEditor라는 것을 접하게 되었고 검색을 해보았다. 이번 작업도.. 스프링과 매치되는 부분이 있다니..
황당할 따름이다. 툴 작업이라.. 스레드에 전혀 관심을 안두었던 내게.. 약간의 찜찜함을 남겨준다.

property를 이용해 xml로 쏘고 읽는건 해봤으니.. 약점이 있더라도 propertyEditor를 적용해봐야겠다.

구글에서 propertyeditor sample or example 로 검색을 해봐야겠다. 아..서점도 가야하는데..

스프링 jre 다운 받기


(토비라는 유명한 분 블로그인듯)


Example 10.6: The YesNoDialogAlignmentEditor Class

package oreilly.beans.yesno;
import java.beans.*;
import java.awt.*;

public class YesNoDialogAlignmentEditor extends PropertyEditorSupport 
{  
// These two methods allow the property to be edited in a dropdown list.  
// Return the list of value names for the enumerated type.  

public String[] getTags() 
{    
return new String[] { "left", "center", "right" };  
}  
// Convert each of those value names into the actual value.  

public void setAsText(String s) 
{    
if (s.equals("left")) setValue(new Integer(YesNoDialog.LEFT));    
else if (s.equals("center")) setValue(new Integer(YesNoDialog.CENTER));    
else if (s.equals("right")) setValue(new Integer(YesNoDialog.RIGHT));    
else throw new IllegalArgumentException(s);  
}  
// This is an important method for code generation.  

public String getJavaInitializationString() 
{    
switch(((Number)getValue()).intValue()) 
{    
default:    
case YesNoDialog.LEFT:   return "oreilly.beans.yesno.YesNoDialog.LEFT";    
case YesNoDialog.CENTER: return "oreilly.beans.yesno.YesNoDialog.CENTER";    
case YesNoDialog.RIGHT:  return "oreilly.beans.yesno.YesNoDialog.RIGHT";    }  
}

}

위를를 보니 어떻게 써야할지.. 약간 감은 잡겠다
클래스 PropertyEditorSupport 그중.. 내가 써봐야 할것은.. 아래 메서드 이리라..

PropertyEditor 는, 프로퍼티치를 편집하는 완전한 커스텀 컴퍼넌트를 제공할 수가 있습니다. PropertyEditor 는, 에디터의 컴퍼넌트와 제휴해, PropertyChange 이벤트를 트리거해 프로퍼티치의 변경을 통지합니다.

getCustomEditor 를 호출하는 고레벨인 코드에서는, 컴퍼넌트를 보다 큰 프로퍼티 시트에 짜넣거나 독자적인 다이얼로그에 배치하거나 할 수가 있습니다.


정의:
인터페이스 PropertyEditor 내의 getCustomEditor


반환값:
사용자가 현재의 프로퍼티치를 직접 편집할 수 있도록(듯이) 한다 java.awt.Component. 지원되지 않는 경우는 null



'자바se api > swing' 카테고리의 다른 글

스윙..  (0) 2014.01.02
스윙의 기본적인 멀티스레드 처리방식  (0) 2014.01.02
이벤트처리 스레드;;  (0) 2014.01.02
자바 스윙 겁나 복잡하고 방대함...  (0) 2014.01.02
by givingsheart 2014. 1. 2. 09:24