Skip to main content

For fun: JXTable rollover used for "mouseOver editing"

No replies
Anonymous

Always on the lookout for cool requirements I re-read a blog at
palantirtech.com about a fully interactive table (aka "mouseOver
editing") which wants the cell editor to show up if the mouse is
hovering over it.

http://blog.palantirtech.com/2007/05/17/jtable-mouseover-editing/

Couldn't resist a quick try with standard swingx rollover support. It's
doing a very similar thingy as described in the blog, actually start an
edit on mouseOver, but takes only a couple of lines :-) The core is a
custom RolloverController:

</p>
<p>    public static class EditingRolloverController extends<br />
RolloverController {</p>
<p>        @Override<br />
        protected void rollover(Point oldLocation, Point newLocation) {<br />
            if ((newLocation == null) || (newLocation.x < 0)<br />
                    || !component.hasFocus()) return;<br />
            component.editCellAt(newLocation.y, newLocation.x);<br />
        }</p>
<p>        /**<br />
         * {@inheritDoc}<br />
         * Overridden to set the surrendersFocus property to true.<br />
         */<br />
        @Override<br />
        public void install(JXTable table) {<br />
            super.install(table);<br />
            table.setSurrendersFocusOnKeystroke(true);<br />
        }</p>
<p>        //----- implements/overrides to do nothing in this context<br />
        ...<br />
}</p>
<p>// using<br />
RolloverController controller = new EditingRolloverController();<br />
controller.install(myTable);</p>
<p>

(a runnable example is in my incubator, RolloverExperiments, package
rollover)

It's nowhere near producation quality having some open issues (f.i.
overall usability - how to select?), of course, but a nice (keep in mind
that I'm biased :-) example of how per-cell rollover support can be
helpful. And made me tinker with my older "live" rollover renderer
experiments (see LiveTaskPaneYY classes) - probably the only way to get
a proper "intermediate" (between a pure dead renderer and a full-fledged
active editor) with fine-grained mouse-control (routing the events just
isnt good enough)

Enjoy!
Jeanette

PS: I'm mostly off-line this week, so expect a bit longer reaction times

---------------------------------------------------------------------
To unsubscribe, e-mail: jdnc-unsubscribe@jdnc.dev.java.net
For additional commands, e-mail: jdnc-help@jdnc.dev.java.net