title: How to make a button stop counting below 0, using Java?
body: <p>I'm stuck with this code:</p>
  
  <pre><code>private static String labelPrefix = "Number of  boats added: ";
  private int numClicks = 0;
  
       JLabel addb = new JLabel(labelPrefix + "0    "); 
       JButton del = new JButton("Delete Boat!"); 
  
          panel.add(addb);
           addb.setText(labelPrefix + --numClicks);
            del.setVisible(true);
  </code></pre>
  
  <p>When delete button is pressed it counts down from labelPrefix, but I need it to stop at 0 and not go to negative side. Any ideas how I could do it without changing a lot? </p>