Geertjan's Blog

  • September 11, 2006

How to Suppress Editing in a TreeTableView

Geertjan Wielenga
Product Manager
In How to Sort Columns in a TreeTableView, an MP3 Manager (on the NetBeans Platform) was shown that had properties that were not editable. However, there were small "..." (i.e, elipsis) buttons next to each property, for editing. How to get rid of those little buttons? Several people have asked about this on the mailing list and recently Jesse Glick provided an answer.

So, this is the starting point:

Then add one line to the Constructor in each PropertySupport.ReadWrite implementation class:


...and you end up without the small elipsis buttons:

For details on "suppressCustomEditor" and many other properties, see Customizing how Properties are displayed. (Yes, it is in the Javadoc, but like many parts of the Javadoc, this is a very well described, discursive article, rather than the barebones descriptions that most non-NetBeans Javadoc tend to consist of.)

If you remove the content of the setValue() method, then you won't be able to edit the value inline either. So, this is one of the properties, in the MP3 Manager:

public class ArtistProperty extends PropertySupport.ReadWrite {
public ArtistProperty() {
super(DetailInterface.ARTIST_DESC, String.class, "Artist", "Name of Artist");
public Object getValue() throws IllegalAccessException, InvocationTargetException {
return movie.getTags().elementAt(0);
public void setValue(Object newValue) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException {

However, if you change PropertySupport.ReadWrite to PropertySupport.ReadOnly, you'll see the values greyed out:

You might wonder why, if you've set the property as ready only, the elipsis buttons are shown anyway (unless you set the "suppressCustomEditor" property shown above)? Well, Jesse's answer on the list makes sense to me: "For long property values you can use the dialog from "..." to see (and copy) the complete value, even if r/o." In fact, this is also the case for several properties in the IDE itself. In other words, even though there are several properties (e.g., on a file) that can't be edited, you still get that button, so that you can potentially see the value (if it is too long to fit in the column) and copy the value more easily too.

The only remaining problem with this solution is that, while the application is called "MP3 Manager", there is absolutely nothing that can be managed, because nothing is editable anymore... Hmmm. Two ways to fix that. Either make everything editable, or... rename the application to "MP3 Viewer". So, either fix the problem or recast it as a feature. A classic programming dilemma...

Join the discussion

Comments ( 2 )
  • Eoin O'Meara Wednesday, June 13, 2007
    When I update a property by code in the background the property is only visually updated in the property window when I click on the old value, ie as soon as I click on the old value it changes to the new value.
    How do I get this to happen automatically, i.e
    without the click?
    Thanks in Advance!
  • Ales Wednesday, June 11, 2008

    Is there any option tu turn off displaying the edit buttons and let it show only when the cell goes into editing state? This is default JTable behaviour...

    Thanks for any hints

Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.