title: MouseDragged is not working
body: <p>can someone help me with this please, I have been following a book on learning to program in Java, copied one of their programs and thou it works the mouseDragged is not working. Cannot click on the ‘Hello Java!’ text and drag it round the screen. I have included the program but I just can’t see where I have gone wrong or what I have misted out.
  I have seen the post: "MouseDragged &amp; MouseMoved not working in Java Applet", but those methods are all in my program.</p>
  
  <pre><code>//file: HelloJava3.java
  import java.awt.*;
  import java.awt.event.*;
  import javax.swing.*;
  
  
  public class HelloJava3 {
  
  public static void main(String[] args) {
      JFrame frame = new JFrame("HelloJava3");
      frame.add( new HelloComponent3("Hello, Java!"));
      frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE);
      frame.setSize(300, 300);
      frame.setVisible(true);
  
  }
  
  }
  
  class HelloComponent3 extends JComponent
  implements ActionListener, MouseMotionListener
  {
      String theMessage;
      int messageX = 125, messageY = 95; //Coordinates of the message
  
      JButton theButton;
  
      int colorIndex; //Current index into someColors
      static Color[] someColors = {
              Color.black, Color.red,               Color.green,  Color.blue,  Color.magenta
      };
  
  public HelloComponent3(String message) {
      theMessage = message;
      theButton = new JButton("Change Color");
      setLayout(new FlowLayout());
      add(theButton);
      theButton.addActionListener(this);
      addMouseMotionListener(this);
  }
  
  public void paintComponent(Graphics g) {
      g.drawString(theMessage, messageX, messageY);
  }
  
  public void mouseDgragged(MouseEvent e) {
      messageX = e.getX();
      messageY = e.getY();
      repaint();
  }
  
  public void mouseMoved(MouseEvent e) {}
  
  public void actionPerformed(ActionEvent e) {
      // Did somebody push out button?
      if (e.getSource() == theButton)
          changeColor();
  }
  
  synchronized private void changeColor() {
      //Change the index to the next colour, awkwardly.
      if (++colorIndex == someColors.length)
          colorIndex = 0;
      setForeground(currentColor()); // Use the new colour.
      repaint();
  }
  
  synchronized private Color currentColor() {
      return someColors[colorIndex];
  }
  
  @Override
  public void mouseDragged(MouseEvent arg0) {
      // TODO Auto-generated method stub
  
  }
  }
  </code></pre>