Freitag, 18. Dezember 2015

MBassador PublicationErrorHandler

I was very confused when my thrown events didn't show any results somewhen. And then, I realized I did not pay enough attention, because MBassador was indeed very nice to suggest registering an ErrorHandler for publication failures. The documentaiton is quite sparse about that, it took me some time to figure it out, so with version around 1.2.4, this is the way you can do it:

 IBusConfiguration config = new BusConfiguration()  
  .addFeature(Feature.SyncPubSub.Default())  
  .addFeature(Feature.AsynchronousHandlerInvocation.Default())  
  .addFeature(Feature.AsynchronousMessageDispatch.Default())  
  .addPublicationErrorHandler(error -> {  
    System.out.println(error);  
  });  
 new MBassador(config);  

Swing reload JTree

So many people want to know how a JTree in for example a JScrollPane can be reloaded. To make it short, no revalidating, no repainting by hand - just:

 DefaultTreeModel model = (DefaultTreeModel)getModel();  
 model.reload();  

Call this everytime your underlying data changes and the view will update itself automatically. This is mainly for myself, because I have to look it up again every time I need it...