title: Counting no of vehicles java
body: <p>This is part of my code for a car park system. I am having some problems with using 'count'. Currently, my program adds 1 to the count for every input 'reg no', 'high value' and 'large vehicle'. I want my program to just add 1 every time i enter a new vehicle registration number only? How do I do this? I am not very good with counting in Java. Here is what I have so far:</p>
  
  <pre><code>package carpark;
  
  
  import javax.swing.*; 
  import java.awt.*; 
  import java.awt.event.*; 
  
  public class textBox extends javax.swing.JFrame 
  implements ActionListener 
    { // declare the components and variables 
    private final JLabel inputLabel,inputLabel2,inputLabel3,countLabel; 
    private final JTextField inputBox,inputBox2,inputBox3,countBox; 
    private final JButton enterButton; 
    private final JButton clearButton;
  
    private int count; 
    private String sum; 
    private String inputString, countString; 
    private String sumString; 
  
    public textBox() 
      { // sets up the components and places them 
      this.setLayout(new FlowLayout()); 
      this.inputLabel = new JLabel("Please enter the vehicle's registration number:"); 
      this.inputBox = new JTextField(8); 
      this.inputLabel2 = new JLabel("Is this a high-value car? Enter yes or no:"); 
      this.inputBox2 = new JTextField(4); 
      this.inputLabel3 = new JLabel("Is this a large vehicle? Enter yes or no:"); 
      this.inputBox3 = new JTextField(4); 
      this.countLabel = new JLabel(" Car Count"); 
      this.countBox = new JTextField(3); 
      this.enterButton = new JButton("Enter"); 
      this.clearButton = new JButton("Clear"); 
  
      this.add(inputLabel); 
      this.add(inputBox); 
      this.add(inputLabel2); 
      this.add(inputBox2); 
      this.add(inputLabel3); 
      this.add(inputBox3); 
      this.inputBox.addActionListener(this); 
      this.add(countLabel); 
      this.add(countBox); 
      this.countBox.setEditable(false); 
  
  
      this.add(enterButton); 
      this.enterButton.addActionListener(this); 
      this.add(clearButton); 
      this.clearButton.addActionListener(this); 
      } 
  
      public void actionPerformed(ActionEvent event) 
        { // reacts to the ENTER key being pressed 
        if (event.getSource() == this.enterButton || event.getSource() == this.inputBox) 
        try 
         { 
         this.inputString = inputBox.getText();  
         this.count += 1; 
         this.countString = Integer.toString(this.count); 
         this.countBox.setText(this.countString); 
         } 
  
         catch (NumberFormatException entry) 
         { 
           this.inputBox.setText(""); 
         } 
         else if (event.getSource() == this.clearButton) 
         { 
          this.inputBox.setText(""); 
          this.countBox.setText("");  
          this.count = 0; 
          }  
        } 
    }
  </code></pre>