Korvin Gump Korvin Gump - 1 year ago 48
Java Question

Set category name for bean fields in PropertySheet JavaFX

ContolsFX example for

have several options. First, create a bean with beaninfo. In this case I can't set category for each field in
. I can choose only between basic and expert categories. Second option is to use
, where I can set category for each field. But I want to use beans. Is it possible to set category for bean fields?

public class SampleBeanBeanInfo extends SimpleBeanInfo {

private static final BeanDescriptor beanDescriptor = new BeanDescriptor(SampleBeanBeanInfo.class);
private static PropertyDescriptor[] propDescriptors;

static {
beanDescriptor.setDisplayName("Sample Bean");

public BeanDescriptor getBeanDescriptor() {
return beanDescriptor;

public int getDefaultPropertyIndex() {
return 0;

public PropertyDescriptor[] getPropertyDescriptors() {
if (propDescriptors == null) {
propDescriptors = new PropertyDescriptor[5];
try {
CustomPropertyDescriptor cdp = new CustomPropertyDescriptor("id", SampleBean.class, "getId", "setId");
propDescriptors[0] = cdp;
propDescriptors[1] = new PropertyDescriptor("firstName", SampleBean.class, "getFirstName", "setFirstName");
propDescriptors[1].setDisplayName("First Name");
propDescriptors[2] = new PropertyDescriptor("lastName", SampleBean.class, "getLastName", "setLastName");
propDescriptors[2].setDisplayName("Last Name");
propDescriptors[3] = new PropertyDescriptor("address", SampleBean.class, "getAddress", "setAddress");
propDescriptors[4] = new PropertyDescriptor("hiddenValue", SampleBean.class, "getHiddenValue", "setHiddenValue");
propDescriptors[4].setDisplayName("Hidden Value");
} catch (IntrospectionException ex) {
return propDescriptors;



After investigation, i found that categories are hardcoded and could not be changed when we are using beans. So you should use your custom PropertySheet.Item implementation. In this case we can set any category name for properties. Check out official example in controlsFX project how to do it.