title: How to select a shape on a drawing panel?
body: <p>I am creating a program where I can draw different shapes onto a drawing canvas. I want to add a button that, after clicked, allows me to select a shape and then drag/translate it to a different spot on the canvas. What is the basic concept behind implementing this? When I click on the shape to select it, I want to somehow add a border around it to show that it is selected. </p>
  
  <p>Okay, I tried this and it kind of works. Except, I am able to select multiple shapes and the border that shows its selected does not appear around the shape until after I change radio buttons to do something else. Then the selection appears. I am not sure how to fix this? I tried adding a boolean to fix being able to select multiple shapes, but it isn't working. boolean isSelected is originally set to false. I don't understand why the border color/width doesn't appear automatically on the mouse click. </p>
  
  <pre><code>    public void mousePressed(MouseEvent e) {
          if ((_buttonNumber == 0) || (isSelected)) {
              for(int i=0; i&lt;_storedShapes.size(); i++) {
                  _storedShapes.elementAt(i).contains(e.getPoint());
                  _storedShapes.elementAt(i).setBorderWidth(10);
                  _storedShapes.elementAt(i).setBorderColor(Color.BLACK);
                  isSelected = true;
              }
          }
          else {
              isSelected = false;
          }
  </code></pre>