Monday, November 23, 2009

News - Swing-Generics (OpenJDK): JList patch commited

Great news from the OpenJDK swing-generics project: my patch to "generify" JList, along with AbstractListModel, DefaultListCellRenderer, DefaultListModel, ListCellRenderer and ListModel, has been commited to the OpenJDK/ Swing repository!

This patch helps writing more stable code.

Eg. instead of writing something like:


with this patch you can write now:


Note that:
JList.getSelectedValues(): Object[] has been deprecated and replaced with:
JList.getSelectedValuesList(): List<E>

Have a look at the jtreg tests to see more examples.

If you're interested in the future of Swing, join the discussions in the OpenJDK Swing mailing list.

4 comments:

  1. Congrats, this is a real step forward! Does this also mean that the ListCellRenderer interface will have a generic type?

    ReplyDelete
  2. Yes, ListCellRenderer has a generic type parameter, too. See:
    http://hg.openjdk.java.net/jdk7/swing/jdk/file/7bcb1864f424/src/share/classes/javax/swing/ListCellRenderer.java

    ReplyDelete
  3. That's the parameter I use.

    ReplyDelete