title: How to set up a mouse dragger in Java for la labyrinth?
body: <p>I have a task to set up a mouse dragger to move my square on a labyrinth in Java, I had set up the keys already but strugging to figure out a nice way to add the other one.</p>
  <pre class="lang-java prettyprint-override"><code>public class Player extends JPanel{
      int x, y;
      
      public Player() {
          this.setBackground(Color.getHSBColor(0.3f, 0.3f, 1));
          this.setSize(Maze.panelSize, Maze.panelSize);
      }
  
      public void moveLeft() {
          if(x &gt; 0 &amp;&amp; Maze.map[x-1][y] == 1){
              this.setLocation(this.getX()-25, this.getY());
              x--;
          }
      }
  
      public void moveRight() {
          if(x &lt; Maze.columns-1 &amp;&amp; Maze.map[x+1][y] == 1){
              this.setLocation(this.getX()+25, this.getY());
              x++;
          }
      }
  
      public void moveUp() {
          if(y &gt; 0 &amp;&amp; Maze.map[x][y-1] == 1){
              this.setLocation(this.getX(), this.getY()-25);
              y--;
          }
      }
  
      public void moveDown() {
          if(y &lt; Maze.rows-1 &amp;&amp; Maze.map[x][y+1] == 1){
              this.setLocation(this.getX(), this.getY()+25);
              y++;
          }
      }
  }
  </code></pre>