Hi All

As a beginner, I design a small programm using netbeans(6.1). Actually I designed one class and connected it with several JDialog ,but I find some difficulty with search engin and creating the LinkedList.(how can I connect between them )

main question : if I search fort he customername in the list how can I get all information about this customer . Please modify this code for me . It only works if I search for one word.
I really will appreciate your help !!

// action added to the jBotton

    public int Search4Data() throws FileNotFoundException {
        String CustomerName =null;
        Vector dataList = new Vector();

    String fileName = "d:\\Database.txt";
    File fin = new File (fileName);
    // get the user input
    CustomerName = jTextField2.getText();
    Scanner sc = new Scanner(fin);
        int count=0;
            if(sc.next().equals(CustomerName ))
                dataList.add("The Searched word is : "+CustomerName + sc.next());

        return count;

Edited by Nick Evan: Fixed formatting

9 Years
Discussion Span
Last Post by Ezzaral

Why would you use a loop to search? Look at the methods for the Vector class. Particularly, look at the indexOf method. If you override the equals method from the Object class, then use indexOf, it will return the index of the thing you are looking for. So your "search" code would look like this:

while there are still names to search for{
get the next name from the file
check to see if the name you just got is in your Vector using indexOf
if the index != -1 {
Customer customer = Vector(theIndexIndexOfReturned);


Now, your customer variable will contain the Customer that you were looking for in the Vector.

if (sc.next().equals(CustomerName)) {
                dataList.add("The Searched word is : " + CustomerName + sc.next());

In this part of program You are using two times sc.next() every call returns NEXT value. Use once String any=sc.next() and later use any


If I want to call A linkedList from the main to the search Jdialog ...It is correct if I write ProjectApp.getApplication().getLinkedList();???

second question: where should I write the above script on the Jdialog??

Third question: how can I add the action the button to edit the information by using this method ?? and where should I put it in the JDialog??

public static boolean editForMaid(LinkedList<maids> list, maids m){

         return true;

    return false;

Edited by mike_2000_17: Fixed formatting


These questions make absolutely no sense in the limited context of code that you have posted. You would need to post the relevant code from those other classes if you expect anyone to be able to make a suggestion.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.