search button

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • porky008
    New Member
    • Oct 2006
    • 20

    #1

    search button

    I have this search button working for the most part. I would like it if some one could take a look at it and let me know what I am doing wrong it though. Basically I want it to display movie not found if the movie is not found and can not seem to get it right.

    Code:
     btnSearch.addActionListener(new ActionListener(){
    		  public void actionPerformed(ActionEvent ae){
    			  String Search =JOptionPane.showInputDialog("Enter name of Movie");
    	          int x =0;
    		      for(x = 0; x < dvds.size(); x++)
    		 {
      		    DVD dvd = (DVD)dvds.get(x);
      		System.out.println("title= "+dvd.title+", search = " +Search);
                 if(dvd.title.equals(dvd.title))
      		     if(dvd.title.trim().equalsIgnoreCase(Search.trim()));
      	      {
                 list.setSelectedIndex(x);
        	break;
     	      }
    	     }
    	        if(x == dvds.size()) JOptionPane.showInputDialog("Movie not found.");
     
    		}
       });
Working...