« November 2007 | Main | April 2008 »

December 2007 Archives

December 5, 2007

More reasons I am leaving NetBeans for IntelliJ

Check out this beauty, any decent Swing developer should cringe at this stack trace

java.lang.Object.wait(Native Method)
java.lang.Object.wait(Object.java:485)
org.netbeans.modules.debugger.jpda.JPDADebuggerImpl.waitRunning(JPDADebuggerImpl.java:290)
org.netbeans.modules.debugger.jpda.JPDADebuggerImpl.finish(JPDADebuggerImpl.java:1039)
org.netbeans.modules.debugger.jpda.actions.KillActionProvider.doAction(KillActionProvider.java:74)
org.netbeans.api.debugger.ActionsManager.doAction(ActionsManager.java:158)
org.netbeans.api.debugger.Session.kill(Session.java:278)
org.netbeans.modules.debugger.ui.models.SessionsActionsProvider$3.perform(SessionsActionsProvider.java:97)
org.netbeans.spi.viewmodel.Models$ActionSupport.actionPerformed(Models.java:528)
javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1995)
javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2318)
javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:387)
javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:242)
javax.swing.AbstractButton.doClick(AbstractButton.java:357)
javax.swing.plaf.basic.BasicMenuItemUI.doClick(BasicMenuItemUI.java:1216)
javax.swing.plaf.basic.BasicMenuItemUI$Handler.mouseReleased(BasicMenuItemUI.java:1257)
java.awt.Component.processMouseEvent(Component.java:6038)
javax.swing.JComponent.processMouseEvent(JComponent.java:3265)
java.awt.Component.processEvent(Component.java:5803)
java.awt.Container.processEvent(Container.java:2058)
java.awt.Component.dispatchEventImpl(Component.java:4410)
java.awt.Container.dispatchEventImpl(Container.java:2116)
java.awt.Component.dispatchEvent(Component.java:4240)
java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4322)
java.awt.LightweightDispatcher.processMouseEvent(Container.java:3986)
java.awt.LightweightDispatcher.dispatchEvent(Container.java:3916)
java.awt.Container.dispatchEventImpl(Container.java:2102)
java.awt.Window.dispatchEventImpl(Window.java:2429)
java.awt.Component.dispatchEvent(Component.java:4240)
java.awt.EventQueue.dispatchEvent(EventQueue.java:599)
java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:273)
java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:183)
java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:173)
java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:168)
java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:160)
java.awt.EventDispatchThread.run(EventDispatchThread.java:121)

Yes, Netbeans totally froze up on me, because some overworked programmer thought it would be good to do a blocking wait without timeout in the Swing Event Dispatch Thread. If a single problem happens you are stuck in limbo forever. Which is why non-timeout wait calls can be so evil, and doing it in the EDT makes it demonic. Looks like we need to get the stick back out, or punish whoever it is that violated their blood oath.

Really, I'm not just being petty. I've sent may stack traces like this to the bugzilla at NetBeans for years, literally years, and they still are doing messed up things in their action handlers without checking to see if they are in the EDT. It may have the best GUI designer for Java out there, but the frosting doesn't matter if you cannot stomach the cake.

December 7, 2007

New Swing Features in Groovy 1.5

Groovy 1.5 has been released. Yes, this is the former 1.1-rc line, and a late decision was made to brand it Groovy 1.5. It's more than the typical incremental improvements, but not quite a major release (by a hair), so at the prompting of Alexandru Popescu we went for a release number that shows compatibility with Java 1.5 features.

In addition to the basic language level changes, there are a lot of changes that went into Groovy's Swing support.

Backend overhaul

  • Almost every line in the SwingBuilder was adjusted in some way. And the whole thing was ported over to Groovy from Java. Dogfood baby!
  • FactoryBuilderSupport is a juiced up refactoring of SwingBuilders building pattern. SwingBuidler is now a subclass of FactoryBuidlerSupport fully using Factories for all of it's classes, and node specific handling has similarly been moved to the factories out of the SwingBuidler core.
  • At the FactoryBuilderSupport level a new build() method was added, so external Groovy Scripts can be called and executed as though they are builder content directly.
  • Also at the FBS level nodes that create object that should be disposed are tracked via addDisposalClosure(), which are all called in FILO order from the dispose() method.
  • Most nodes now accept an object of their own type, providing another point of extension. i.e. button(new MyCustomButton()) works as expected if MyCustomButton extends JButton

New Nodes

  • actions(), a simple collection node that is meant to describe actions
  • imageIcon() provides support for ImageIcons
  • Borders are now supported via buidler nodes. lineBorder(), loweredBevelBorder(), raisedBevelBorder(), etchedBorder(), loweredEtchedBorder(), raisedEtchedBorder(), titledBorder(), emptyBorder(), compoundBorder(), and matteBorder().
  • bind() and model(), adding binding support for observable properties.
  • The passthrough widget() now has two use specific cousins, container() for widgets that can have children (widget() now throws an error when children are added) and bean(), which will not add the resulting object to the parent container. (Note that the expanded argument support for the basic nodes should reduce the necessity of these nodes. Just add the new widget as an argument to it's javax.swing type.)

New Methods

  • edt(Closure), executes the Closure in the Event dispatch Thread (EDT) and wait for completion (via SwingUtilities.invokeAndWait). Optimizations are performed for when the method is called in the EDT.
  • doLater(Closure), executes the Closure in the EDT asynchronously via SwingUtilities.invokeLater()
  • doOutside(Closere), insures that the closure is executed outside of the EDT. If the context is not in the EDT it is executed immediately, otherwise a new thread is created
  • shortcut(key [, modifiers]), given a keystroke it adds a platform specific modifier for it (ctrl on Windows and GTK, option on MacOS).
  • dispose() invokes all disposal closures. Generally these are things such as dialogs, frames, and windows created by the SwingBuilder and unbinds all bindings created by bind().
  • lookAndFeel() is an easy way to set the look and feel. Defaults exist for system, metal, nimbus, etc. and a few third party LAFs.

New static method

  • build(Closure), creates and returns a SwingBuilder and executes the closure in context of the Event Dispatch Thread.

About December 2007

This page contains all entries posted to ... And They Shall Know Me By My Speling Errors in December 2007. They are listed from oldest to newest.

November 2007 is the previous archive.

April 2008 is the next archive.

Many more can be found on the main index page or by looking through the archives.

Powered by
Movable Type 3.33