try { Component selected = (Component)designer.getSelectedWidget(); if (selected != null) {  Point origin = SwingUtilities.convertPoint(selected.getParent(), new Point(0,0), this); ((Graphics2D)g).translate(origin.x, origin.y);  Point p = selected.getLocation(); Dimension d = selected.getSize();  g.setColor(new Color(50, 50, 255, 128)); g.fillRect(p.x, p.y, d.width, d.height);  Anchor a = Anchor.getNSAnchor(selected); if (a != null) a.drawConnector(g); a = Anchor.getEWAnchor(selected); if (a != null) a.drawConnector(g); } } catch (Exception ex) {ex.printStackTrace();} }
try { Component selected = (Component) designer.getSelectedWidget(); if (selected != null) {  Anchor a = Anchor.getNSAnchor(selected); if (a != null) a.drawConnector(this, g); a = Anchor.getEWAnchor(selected); if (a != null) a.drawConnector(this, g);  Point origin = SwingUtilities.convertPoint( selected.getParent(), new Point(0, 0), this);  ((Graphics2D) g).translate(origin.x, origin.y);  Point p = selected.getLocation(); Dimension d = selected.getSize();  g.setColor(new Color(50, 50, 255, 128)); g.fillRect(p.x, p.y, d.width, d.height);  } } catch (Exception ex) { ex.printStackTrace(); } }
	public void paint(Graphics g) {		try {			Component selected = (Component)designer.getSelectedWidget();			if (selected != null) {				// todo: clip to viewport				Point origin = SwingUtilities.convertPoint(selected.getParent(),						new Point(0,0),						this);				((Graphics2D)g).translate(origin.x, origin.y);								Point p = selected.getLocation();				Dimension d = selected.getSize();				// todo: get a color from l&f				g.setColor(new Color(50, 50, 255, 128));				g.fillRect(p.x, p.y, d.width, d.height);								Anchor a = Anchor.getNSAnchor(selected);				if (a != null)					a.drawConnector(g);				a = Anchor.getEWAnchor(selected);				if (a != null)					a.drawConnector(g);			}		} catch (Exception ex) {ex.printStackTrace();}	}