|
JavaTM Platform Standard Ed. 6 |
|||||||||
앞의 클래스 다음의 클래스 | 프레임 있어 프레임 없음 | |||||||||
개요: 상자 | 필드 | 생성자 | 메소드 | 상세: 필드 | 생성자 | 메소드 |
java.lang.Objectjavax.swing.JFormattedTextField.AbstractFormatter
javax.swing.text.DefaultFormatter
javax.swing.text.InternationalFormatter
javax.swing.text.NumberFormatter
public class NumberFormatter
NumberFormatter
는, 수에 관한 특수한 동작을 추가하는 InternationalFormatter
를 서브 클래스화합니다. 특수화에는 이하가 포함됩니다 (이것들은,setAllowsInvalid(false)
와 같이,NumberFormatter
이 무효인 수를 표시하지 않는 경우에만 사용된다).
DecimalFormat
에 관련하는 DecimalFormatSymbols
로부터 판별된다)를 누르면(자), 수의 부호의 정/부에의 변경이 시도된다
DecimalFormat
에 관련하는 DecimalFormatSymbols
로부터 판별된다)를 누르면(자), 지수의 부호의 정/부에의 변경이 시도된다
과학적 수치 표기를 사용하고 있는 경우는, 덧쓰기 모드(replace mode) setOverwriteMode(true)
를 온으로 합니다. 다음에 예를 나타냅니다.
DecimalFormat decimalFormat = new DecimalFormat("0.000E0"); NumberFormatter textFormatter = new NumberFormatter(decimalFormat); textFormatter.setOverwriteMode(true); textFormatter.setAllowsInvalid(false);
사용자에게 10 진수값의 입력을 허가하는 경우, DecimalFormat 에 적어도 1 개의 10 진수 (#. 0###
)(을)를 갖게하는지, 무효인 setAllowsInvalid(true)
가 되는 값을 허가할 필요가 있습니다. 그렇지 않은 경우, 사용자는 10 진수값를 입력할 수 없습니다.
NumberFormatter
에서는, 슈퍼 클래스와는 조금 다른 동작을 stringToValue
에 제공합니다. 값의 Class 로서Integer
,Long
,Float
,Double
,Byte
,Short
의 어느쪽이든을 지정 (DefaultFormatter.setValueClass(java.lang.Class >)
) 하고 있어, Format 의 parseObject
가 Number
의 인스턴스를 돌려주는 경우, 값클래스의 대응하는 인스턴스는, 값클래스가 나타내는 원시형에 적절한 생성자 을 사용해 작성됩니다. 다음에 예를 나타냅니다. setValueClass(Integer.class)
는, 결과적으로 new Integer(((Number) formatter.parseObject(string)). intValue())
로 작성되는 값이 됩니다. 전형적인 예로서 다양한 Number
의 구현이 일반적으로 서로끼리를 비교할 수 없을 때에, 최대치나 최소치를 설정하는데 도움이 됩니다. 또, 하등의 이유로써 값에 특별한 Number
의 구현이 필요한 때에도 도움이 됩니다.
경고: 이 클래스의 직렬화 된 객체는, 향후의 Swing 릴리스와 호환은 아니게 될 예정입니다. 현재의 직렬화의 지원는, 단기간의 운용이나, 같은 버젼의 Swing 를 실행하는 어플리케이션간의 RMI 에 적절하고 있습니다. JDK Version 1.4 이후, 모든 JavaBeans™ 의 장기간의 운용 지원는,java.beans
패키지에 추가되고 있습니다. 자세한 것은,XMLEncoder
를 참조해 주세요.
생성자 의 개요 | |
---|---|
NumberFormatter ()
NumberFormat.getNumberInstance() 로부터 취득한 디폴트의 NumberFormat 인스턴스를 사용해 NumberFormatter 를 작성합니다. |
|
NumberFormatter (NumberFormat format)
지정한 Format 인스턴스를 사용해, NumberFormatter 를 작성합니다. |
메소드의 개요 | |
---|---|
void |
setFormat (Format format)
편집 및 표시가 가능한 정당한 값을 규정하는 서식을 설정합니다. |
클래스 javax.swing.text. InternationalFormatter 로부터 상속된 메소드 |
---|
clone , getActions , getFields , getFormat , getMaximum , getMinimum , install , setMaximum , setMinimum , stringToValue , valueToString |
클래스 javax.swing.text. DefaultFormatter 로부터 상속된 메소드 |
---|
getAllowsInvalid , getCommitsOnValidEdit , getDocumentFilter , getNavigationFilter , getOverwriteMode , getValueClass , setAllowsInvalid , setCommitsOnValidEdit , setOverwriteMode , setValueClass |
클래스 javax.swing. JFormattedTextField.AbstractFormatter 로부터 상속된 메소드 |
---|
getFormattedTextField , invalidEdit , setEditValid , uninstall |
클래스 java.lang. Object 로부터 상속된 메소드 |
---|
equals , finalize , getClass , hashCode , notify , notifyAll , toString , wait , wait , wait |
생성자 의 상세 |
---|
public NumberFormatter()
NumberFormat.getNumberInstance()
로부터 취득한 디폴트의 NumberFormat
인스턴스를 사용해 NumberFormatter
를 작성합니다.
public NumberFormatter(NumberFormat format)
format
- 정당한 값의 규정에 사용하는 서식메소드의 상세 |
---|
public void setFormat(Format format)
null 의 생성자 을 사용했을 경우, 이 프로퍼티의 값은,NumberFormat.getNumberInstance()
메소드에 의해 현재의 로케일로 결정됩니다.
InternationalFormatter
내의 setFormat
format
- 적정한 값의 규정에 사용하는 NumberFormat 인스턴스
|
JavaTM Platform Standard Ed. 6 |
|||||||||
앞의 클래스 다음의 클래스 | 프레임 있어 프레임 없음 | |||||||||
개요: 상자 | 필드 | 생성자 | 메소드 | 상세: 필드 | 생성자 | 메소드 |
Copyright 2006 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms . Documentation Redistribution Policy 도 참조해 주세요.