ComboBoxPropertyDescriptor怎么实现属性的选择
ComboBoxPropertyDescriptor如何实现属性的选择?
被这个问题困扰很久了,想要实现属性选择,比如在value1,value2,value3中,用户可以在属性视图上进行选择。
结果程序一直有问题,但是我觉得我没有错,求大神指点。困扰好久了。
下面是程序:
public class AxisMotion extends Node {
public static final String PROP_AXIS_TYPE = "axis_type";
public String displacementType,axisType;
protected IPropertyDescriptor[] descriptors = new IPropertyDescriptor[] {
new ComboBoxPropertyDescriptor(PROP_AXIS_TYPE,
"axis type",
new String[] { "rotate", "shift" }) ,
};
public String getAxisType() {
return axisType;
}
public void setAxisType(String axisType) {
this.axisType = axisType;
firePropertyChange(PROP_AXIS_TYPE,null,axisType);
}
public Object getEditableValue() {
return this;
}
public IPropertyDescriptor[] getPropertyDescriptors() {
return descriptors;
}
public Object getPropertyValue(Object id) {
super.getPropertyValue(id);
if(id.equals(PROP_AXIS_TYPE)){
if(this.getAxisType().equals("rotate")){
return new Integer(0);
}
return new Integer(1);
}
return null;
}
public boolean isPropertySet(Object id) {
return true;
}
public void resetPropertyValue(Object id) {
}
public void setPropertyValue(Object id, Object value) {
super.setPropertyValue(id, value);
if(id.equals(PROP_AXIS_TYPE)){
if(((Integer) value).equals( new Integer(0))){
this.setAxisType("rotate");
}
this.setAxisType("shift");
}
}
------解决方案--------------------
解决就好
被这个问题困扰很久了,想要实现属性选择,比如在value1,value2,value3中,用户可以在属性视图上进行选择。
结果程序一直有问题,但是我觉得我没有错,求大神指点。困扰好久了。
下面是程序:
public class AxisMotion extends Node {
public static final String PROP_AXIS_TYPE = "axis_type";
public String displacementType,axisType;
protected IPropertyDescriptor[] descriptors = new IPropertyDescriptor[] {
new ComboBoxPropertyDescriptor(PROP_AXIS_TYPE,
"axis type",
new String[] { "rotate", "shift" }) ,
};
public String getAxisType() {
return axisType;
}
public void setAxisType(String axisType) {
this.axisType = axisType;
firePropertyChange(PROP_AXIS_TYPE,null,axisType);
}
public Object getEditableValue() {
return this;
}
public IPropertyDescriptor[] getPropertyDescriptors() {
return descriptors;
}
public Object getPropertyValue(Object id) {
super.getPropertyValue(id);
if(id.equals(PROP_AXIS_TYPE)){
if(this.getAxisType().equals("rotate")){
return new Integer(0);
}
return new Integer(1);
}
return null;
}
public boolean isPropertySet(Object id) {
return true;
}
public void resetPropertyValue(Object id) {
}
public void setPropertyValue(Object id, Object value) {
super.setPropertyValue(id, value);
if(id.equals(PROP_AXIS_TYPE)){
if(((Integer) value).equals( new Integer(0))){
this.setAxisType("rotate");
}
this.setAxisType("shift");
}
}
------解决方案--------------------
解决就好