The Caboteria / Tech Web / TechNotes > ProgrammingNotes > JavaNotes / JHotDrawNotes (12 May 2005, TobyCabot)
JHotDraw is a framework for building Swing drawing applications. It's descended from a toolkit written in SmallTalk by one of the "gang of four" patterns gurus so it's heavily pattern-intensive.

What happens when the delete key is pressed?

     at reva.manager.view.editor.Antenna$1.figureRequestRemove(
     at org.jhotdraw.standard.StandardDrawing.orphan(Unknown Source)
     at org.jhotdraw.standard.DeleteFromDrawingVisitor.visitFigure(Unknown Source)
     at org.jhotdraw.standard.AbstractFigure.visit(Unknown Source)
     at org.jhotdraw.standard.FigureTransferCommand.deleteFigures(Unknown Source)
     at org.jhotdraw.standard.DeleteCommand.execute(Unknown Source)
     at org.jhotdraw.util.UndoableCommand.execute(Unknown Source)
     at org.jhotdraw.standard.StandardDrawingView$DrawingViewKeyListener.keyPressed(Unknown Source)
     at java.awt.Component.processKeyEvent(

StandardDrawingView.DrawingViewKeyListener creates a DeleteCommand in the constructor. When the delete key is pressed the listener calls DeleteCommand.isExecutable() and if it returns true calls execute(). DeleteCommand.isExecutable() checks some stuff and then delegates to DeleteCommand.isExecutableWithView() which checks if any figures are selected and if so returns true.

Keyboard/mouse events start in the DrawingView (it's a JPanel) and then get propagated to the tool that the DrawingEditor returns from a call to tool().

What happens when the mouse is dragged?

     [java]     at reva.manager.view.editor.AntennaFigure.basicMoveBy(
     [java]     at org.jhotdraw.standard.AbstractFigure.moveBy(
     [java]     at org.jhotdraw.standard.DragTracker.mouseDrag(
     [java]     at org.jhotdraw.util.UndoableTool.mouseDrag(
     [java]     at org.jhotdraw.standard.SelectionTool.mouseDrag(
     [java]     at org.jhotdraw.contrib.CustomSelectionTool.mouseDrag(
     [java]     at org.jhotdraw.standard.StandardDrawingView$DrawingViewMouseMotionListener.mouseDragged(
     [java]     at org.jhotdraw.contrib.zoom.ZoomDrawingView$2.mouseDragged(
     [java]     at java.awt.Component.processMouseMotionEvent(
     [java]     at javax.swing.JComponent.processMouseMotionEvent(
     [java]     at java.awt.Component.processEvent(
Edit | Attach | Print version | History: r4 < r3 < r2 < r1 | Backlinks | Raw View | Raw edit | More topic actions
Copyright © 2008-2018 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding The Caboteria? Send feedback