Mac Widgets for Java – 0.9.5

June 23, 2009

I’ve just released Mac Widgets for Java 0.9.5 (download it here). The major addition in this release is an iTunes style table. I’ve also added a HUD style radio button, made HUDs transparent on non-Mac platforms and completed a number of SourceList enhancements and bug fixes.

Users of the Unified Tool Bar and Bottom Bar will note that these components have been promoted to full classes rather than the awkward factory methods (which had been located in MacWidgetFactory). The API is still evolving, most liking breaking API consumers on upgrade, which is why I’m keeping the library pre-1.0.

You’ll find the full list of enhancements and fixes here, or you can browse the API here. Also, you can see an example that uses the new iTunes table here.

33 Responses to “Mac Widgets for Java – 0.9.5”

  1. Lars Says:

    Amazing! I’m going to give it a test drive soon :)

  2. knalli Says:


    there are some api changes (as you mentioned):
    toolBar.addComponentToLeft(JComponent, int) – the last param (spacing) was removed.. is there any reason?

    And there is a problem with the background painting within the iTunes-Table-Renderer.. when overriding TableModel.getColumnClass(), it will paint opaque white backgrounds like here:
    Furthermore, it seems that the table does support setTableSorter, but will not dislay the arrows (but clicking do sorting). How to use your sorting delegator?

    • Ken Says:

      Hi knalli,

      Re. UnifiedToolBar
      The toolBar.addComponentToLeft(JComponent, int) was only exposed because a TriAreaComponent was being handed back. TriAreaComponent is a general purpose component, whereas UnifiedToolBar is a targeted component with specific UI guidelines. In general, you shouldn’t need to provide spacers between your components, as UnifiedToolBar will put the appropriate amount of space between each item. If you really need a spacer, you can use MacWidgetFactory.createSpacer(width, height) and add the returned JComponent to the UnifiedToolBar.

      Re. iTunes Table
      If your installing custom renderers, make sure to set them to be non-opaque (setOpqaue(false)). I’m not sure what you mean by “the table does not support setTableSorter”? The SortDelegate you install via the TableUtils.makeSortable is responsible for triggering the actual sorting (the name of my utility method is obviously confusing). I’d recommend using Glazed Lists as your backing data mechanism, which can handle sorting and filtering easily.


      • knalli Says:


        Re. iTunes Table
        No, i said “it does support it”. In your screenshot are some kinds of arrows visible. But if I install a tablesorter via setTableSorter there will be no ones. Is this the wrong approach? Better GlazedList?

        I think, you missunterstood me in “custom renderers”. If you override the method getColumnClass(), it will return the according class, e.g. painting a checkbox for booleans. How can I change the behavior of macwidegt’s iTunes-table? I didn’t get it.

  3. Ken Says:

    I’m not sure what the “setTableSorter” method is that your referring to — the method I provide is TableUtils.makeSortable. My method installs listeners on the table header and toggles a sort indicator based on user clicks on that header. The installed listeners will also notify the given SortDelegate that sorting should be performed. Mac Widgets for Java *does not* provide any type of sorting though.

    Follow the sorting indicator example here — if that isn’t working for you, let me know.

    The deafult renderers provided in Java are opaque, so you’ll need to override JTable.prepareRenderer or iterate over all the installed renderers to ensure that they are marked as not opaque.

  4. knalli Says:

    I can only refer to the prior version, I used the TableRowSorter via table. setRowSorter() (sorry, misspelled in lasts postings). This is still working, but seems to be have no visual special styles.. well, because of not using the SortDelegate way? :)

    Okay. I can only give you my external and visual feedback. I didn’t know that the internal itunes-table-renderer was changed so much.

    • Ken Says:

      Hi knalli,

      The sorting indicators are not currently setup to work out-of-the box with TableRowSorter, as that is a JDK 6 feature and I’m currently supporting JDK 5.

      Feel free to create an issue for such a feature.


      • knalli Says:

        Thank you, Ken!

        I’d just overviewed TableRowSorter was java6 only and your support of jdk5.

        Because my app is jdk6+, I prefer a workaround. Simple solution with an empty SortDelegate-object (but not null). That’s not nice, but will help. ;)

        Anyway.. good work.

  5. Sakuraba Says:

    You, sir, are a genius.

    Any chance of a webstartable showcase one day? ;)

    • Ken Says:

      Thanks Sakuraba! I’ve been thinking about adding Web Start-able examples — just haven’t gotten around to it yet.


  6. ranjith Says:

    Awesome by all means.
    Just a nagging/not so important observation regarding iTunes table.
    May be this is nearly nerve racking to get done in Java. When we click to edit on a table cell, in Swing the whole cell becomes the editor(eg: text box)
    But in iTunes table, the text box would be just as long as the text inside the cell – then it grows/shrinks based on what is typed in to the cell.
    Also, dependency on jgoodies is apparently not documented anywhere – again not important :)

  7. Thasso Says:

    hi ken,

    great job ! i really like the itunetable ! integration with glazedlists was almost straight forward and it worked like a charm.
    only minor drawback is the opaque state of the default renderer. you suggested to iterate over all renderer (which is what i do now) or override JTable.prepareRenderer ( but I can not extend ITunesTable as its package private ).
    Wouldn’t it make sense to put that in the ITunesTable directly ? I would still be able to add opaque renderer afterwards, but the table UI basically relies on non opaque renderer and making all default renderer non opaque would make the UI look as expected. But anyways, just a suggestion, keep up the great work !!!

    cheers, thasso

    • Ken Says:

      Hi thasso,

      Glad to hear integration with the iTunes table and Glazed Lists was straight forward! You’re right about the renderers — I should iterate over all the default renderers and set their opacity to false. I’ll make this change.


    • Ken Says:

      FYI, I’ve fixed the opacity problem with renders. In fact, now you can install any renderer you want, with any opacity, and ITunesTableUI will fix the opacity at render time via a custom CellRendererPane.


  8. Tom Says:

    Great job!

  9. Harald K. Says:

    Great work!

    Looks really good, as always! :-)

    Just curious: Did you find a good solution to the table header client properties, or did you end up with your own custom properties?


  10. Ken Says:

    Thanks Harald! I haven’t found a work-around yet for Mac client properties issue, so I’m using my own custom client properties (e.g. “EP” + “JTableHeader.sortDirection”).

    For those unaware of the problem, Apple installs a new header renderer when you set one of the observed client properties on it. This is problematic if you have already installed you’re own header renderer, which can react to said client properties. I plan to continue looking into it.


  11. […] Some days after Kenneth Orr published the lates stable version of Mac Widgets, i created a maven build of it. […]

  12. Daniel Says:

    Hello there,

    first of all, I want to thank you for this great library! It really makes Java-applications look a lot better, in my opinion.

    However, since version 0.9.5 I have some problems according to the iTunesTable. I use NetBeans and the NetBeans GUI Designer for my application. This means, that I have some predefined code which is not editable. In this automatic code generation, a table is created first, and then a table model is associated to that table. Thus, I used following code-line for creating iTunesTables:

    jTableLinks = MacWidgetFactory.createITunesTable(null);

    using mac widgets 0.9.4 everything was fine. But since version 0.9.5 two bugs appeared:

    1.) the above mentioned table column bug, where some columns have no alternating row-colours, but only completely white.

    2.) the auto-column-resize-behaviour has changed. I always used JTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS. Now, when I resize a table column, all subsequent columns are moved and not resized, i.e. the table width changes (which is not intended).

    Is there a way to prevent these two “bugs”?

    • Ken Says:

      Hi Daniel,

      Glad your finding the library useful!

      Re. 1: Can you submit an issue for that? Include sample code if possible.

      Re. 2: The new resize behavior is not a bug, but instead is the actual resize behavior of an iTunes table. You’re free to change this on the returned JTable, but the default will remain JTable.AUTO_RESIZE_OFF.


      • Daniel Says:

        Hello Ken,

        thanks for the fast reply. I have submitted an issue including a screenshot. It looks like columns that have integer-data (java.lang.Integer.class) assigned in the column-model do not render correctly.

        @2: Is there a way to set a default-resize-behaviour for the iTunesTables? It would safe some work, since I use many tables and would have to add everywhere a code-line for the “new” resize-behaviour. ;-)

  13. Daniel Says:

    Perhaps I should add, that my application used the latest JDK6 on Mac…

  14. Harold Says:

    Hello Ken,

    I’ve been very happy with 0.9.4 and was excited to see the new release even though I’d have to work through some of the api changes.

    I do have a problem with the my custom cell rendering. It appears that the cell renderer does not display selected cells. see image:

    I need to be able to display a JLabel component with an icon and text. Let me know if you need me to log a ticket for this.

    Also, my data model return a long value that doesn’t have a custom cell renderer but shows up as opaque and thus doesn’t show striping. I believe you already have a ticket logged against this.

  15. Ken Says:

    Hi Harold,

    Hopefully you’ll find all the API changes are worth the trouble (I think they are!).

    I believe I have fixed the cell rendering issue you mentioned in the latest build. If you’d like, I can email you the most recent jar file.


  16. knalli Says:

    Well, I’d like to get it, too. Alternatively, what yo you think about a small ant task inside the repo building the latest jar?

  17. Daniel Says:

    Ken, if your changes also address my submitted issue, I’d be very happy if you could e-mail me the jar-file as well. Many thanks for your afford!

  18. Elie Says:

    Thanks a lot for this beautiful Library.

    I would love to have also a JSplitPane alternative with a similar behavior to Cocoa’s. I’ve coded one myself for Woopra by extending the JLayeredPane.

  19. Ken Says:

    Hi Elie,

    No problem! As for the split pane, are you referring to a single pixel wide version with a wider “hot spot”? If so, that would definitley be useful.


    • Elie Says:

      No Ken. If you notice the behavior of the Split Pane inside iTunes, you can still drag while pressing on one of the two components. In other words, the splitter should be a transparent component floating “over” the edges of both components, that’s why I used a JLayeredPane for that.

      Here’s a screenshot explained:

  20. Ryan Says:

    I am also having the same problems that Harold mentioned in a previous post: “…I need to be able to display a JLabel component with an icon and text.” When I create a custom cell renderer the row is no longer highlighted and the alternating row colors don’t appear in that column. Is there an update to the .jar file that you could send me. Thank you very much!

  21. Ken Says:

    Hi Ryan,

    There is still an open issue for that item:


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: