21,21d20 < import java.awt.Container; 26,26d24 < import javax.swing.CellRendererPane; 37,37d34 < private transient DrawingEditor myDrawingEditor; 44,45d40 < * @param container the container that provides the screen realestate for paint the component in < * you may use StandardDrawingView 47,47c42,42 < public ComponentFigure(Component newComponent, DrawingEditor newDrawingEditor) { --- > public ComponentFigure(Component newComponent) { 49,49d43 < setEditor(newDrawingEditor); 58a53,53 > * 109a105,105 > * 116,123d111 < protected DrawingEditor getEditor() { < return myDrawingEditor; < } < < protected void setEditor(DrawingEditor newDrawingEditor) { < myDrawingEditor = newDrawingEditor; < } < 130,130c118,118 < //getComponent().setBounds(displayBox()); --- > getComponent().setBounds(displayBox()); 131a120,121 > Graphics componentG = g.create(bounds.x, bounds.y, bounds.width, bounds.height); > getComponent().paint(componentG); 132,165d119 < //Graphics componentG = g.create(bounds.x, bounds.y, bounds.width, bounds.height); < //getComponent().paint(componentG); < < Container container = (Container)getEditor().view(); < getCellRendererPane(component, container).paintComponent(g, component, null, bounds.x, bounds.y, bounds.width, bounds.height, true); < } < < /* This was taken from SwingUtilities < * < * Ensures that cell renderer c has a < * ComponentShell parent and that < * the shell's parent is p. < */ < private static CellRendererPane getCellRendererPane(Component c, Container p) { < Container shell = c.getParent(); < if (shell instanceof CellRendererPane) { < if (shell.getParent() != p) { < p.add(shell); < } < } < else { < shell = new CellRendererPane(); < shell.add(c); < p.add(shell); < } < return (CellRendererPane)shell; < } < < public Object clone() { < ComponentFigure clonedFigure = (ComponentFigure)super.clone(); < // editor cannot be serialized (and should no be serialized < // because that would mean a deep copy) so we set the reference now < clonedFigure.setEditor(getEditor()); < return clonedFigure;