枚举类型的 GUI 用法
枚举类型的可本地化显示字段可以通过使用 getDisplay() 或 getDisplay(locale) 来显示。
要使用 GUI 下拉列表选择中的枚举类型,可将 wt.clients.util.EnumeratedChoice 作为枚举类型的通用控件提供。以下是使用该控件的简单示例:
// construct and initialize a ChoiceBox for an EnumeratedType
EnumeratedChoice mySizeChoice = new EnumeratedChoice();
mySizeChoice.setEnumeratedTypeClassName( "wt.example.MySize" );
// set current choice selection to the current value
mySizeChoice.setSelectedEnumeratedType( myItem.getSize() );
... user makes selection
// obtain the chosen selection
MySize selection =
(MySize)mySizeChoice.getSelectedEnumeratedType();
这对您有帮助吗?