private void endEdit() { if (fURLTarget != null) { setURL(fURLTarget, fTextField.getText()); fURLTarget = null; fTextField.endOverlay(); } }
private Rectangle fieldBounds(Figure figure) { Rectangle box = figure.displayBox(); int nChars = Math.max(20, getURL(figure).length()); Dimension d = fTextField.getPreferredSize(nChars); box.x = Math.max(0, box.x + (box.width - d.width) / 2); box.y = Math.max(0, box.y + (box.height - d.height) / 2); return new Rectangle(box.x, box.y, d.width, d.height); }
private void beginEdit(Figure figure) { if (fTextField == null) { fTextField = new FloatingTextField(); fTextField.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent event) { endEdit(); } }); } if (figure != fURLTarget && fURLTarget != null) { endEdit(); } if (figure != fURLTarget) { fTextField.createOverlay((Container) view()); fTextField.setBounds(fieldBounds(figure), getURL(figure)); fURLTarget = figure; } }