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.

Comments:

Post a Comment:
  • HTML Syntax: NOT allowed
About

Geertjan Wielenga (@geertjanw) is a Principal Product Manager in the Oracle Developer Tools group living & working in Amsterdam. He is a Java technology enthusiast, evangelist, trainer, speaker, and writer. He blogs here daily.

The focus of this blog is mostly on NetBeans (a development tool primarily for Java programmers), with an occasional reference to NetBeans, and sometimes diverging to topics relating to NetBeans. And then there are days when NetBeans is mentioned, just for a change.

Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
12
13
14
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today