Download NetBeans!

20090812 Wednesday August 12, 2009

Two Tips for OutlineViews

Let's now change our BeanTreeView from yesterday to an OutlineView. As you can see, below, you can use an OutlineView as a simple table, with the difference that it is a NetBeans Platform component, meaning that it can benefit from other NetBeans Platform components, such as Nodes.

Let's answer two very frequently asked questions about OutlineViews:

  • Question: How do I change the column name from "Nodes" to something else (such as "Persons") as shown above?

    Answer: Read the related Javadoc and you'll see you can pass in a string when creating the OutlineView. In other words, I added "Persons" instead of "Nodes", like this:

    OutlineView personsOutlineView = new OutlineView("Persons");

  • Question: How do I remove the small "..." buttons next to the properties in the OutlineView?

    Answer: Read the source and you will find a property "suppressCustomEditor". You use it like this, when defining your properties (look at the line in bold below):

    class CityProperty extends PropertySupport.ReadOnly<String> {
    
        private String city;
    
        public CityProperty(String city) {
            super("City", String.class, "City", "City Details");
            setValue("suppressCustomEditor", Boolean.TRUE);
            if (city != null) {
                this.city = city;
            } else {
                this.city = "";
            }
        }
    
        @Override
        public String getValue() throws IllegalAccessException, InvocationTargetException {
            return city;
        }
    
    }

    Only one other property seems to be relevant: "SortableColumn"

Note: Read the related Javadoc and you will see that the first value passed to the superclass of PropertySupport is the name of the property. This name MUST be unique, i.e., if you have two properties with the same first value passed to super, you will have a serious problem that will be hard to debug.

Aug 12 2009, 07:47:38 AM PDT Permalink

Trackback URL: http://blogs.sun.com/geertjan/entry/from_beantreeview_to_outlineview
Comments:

Post a Comment:

Name:
E-Mail:
URL:

Your Comment:

HTML Syntax: NOT allowed