Programmatically Making the Selected OutlineView Cell Editable

When you're using the OutlineView and you use the Tab key to move through its cells, the cells are shown to be selected, as below:

However, until you press the Space key in the selected cell, or until you click the mouse within it, you cannot edit it.

That's extremely annoying when you're creating a data-entry application. Your user would like to begin editing a cell as soon as they have tabbed into it. Needing to press Space first, or click the mouse in the cell first, is a cumbersome additional step that completely destroys your work flow. Below, you can see that an editable cell looks very different to one that is merely selected:

I.e., now I can type and the text changes. How to set up the OutlineView so that the Tab key makes the selected cell editable? Here's the constructor of the TopComponent you see above:

public ViewerTopComponent() {



    setLayout(new BorderLayout());

    OutlineView ov = new OutlineView();

    final Outline outline = ov.getOutline();


    //When column selection changes, e.g., via Tab key,
    //programmatically start editing the cell:
    ListSelectionListener listSelectionListener = new ListSelectionListener() {
        public void valueChanged(ListSelectionEvent e) {
            int row = outline.getSelectedRow();
            int column = outline.getSelectedColumn();
            //Ignore the node column:
            if (row > -1 && row > -1) {
                outline.editCellAt(row, column);

            "city", "City", "state", "State");

    add(ov, BorderLayout.CENTER);

            new AbstractNode(Children.create(new CustomerChildFactory(), true)));

    associateLookup(ExplorerUtils.createLookup(em, getActionMap()));


Thank You for the example !

But Geertjan is it possible for You to prepare small introductory tutorial/blog post about using ETable/OutlineView components ? For me (as a beginner) there is not enough information about it. I'm using nb sources for the lesson part, but easy and comprehensive tutorial would be great!

Posted by guest on April 02, 2012 at 09:49 PM PDT #

Here it is:

Posted by Geertjan on April 02, 2012 at 10:28 PM PDT #

thanks a lot!, i'm digging through Your blog but right now i'm still at the beginning of the 2011 :)

Posted by slawek on April 03, 2012 at 02:06 AM PDT #

For me the issue is to do more advanced stuff like:
1) Not using beans
2) Custom rendering of a column value

Posted by Javier Ortiz on April 03, 2012 at 03:35 AM PDT #

Instead of entering always into edit mode in the most of the cases you want to do it only when user does something, e.g. presses a key.
As Outline is based on JTable you can use JTable.autostartsEdit client property.(see
Unfortunately this solution is not really perfect now, although it is quite elegant. You have to press the first character twice. (see

Posted by Gábor Tóth on April 04, 2012 at 07:00 AM PDT #

Post a Comment:
  • HTML Syntax: NOT allowed

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.


« June 2016