searching for strings in a file

searching for strings in a file

how can i search of a person and display the other details associated with the name using java gui window?

View Answers

August 20, 2011 at 3:43 PM

import java.util.ArrayList;
import javax.swing.*;
import java.awt.event.*;

 class Book{
    int bookid;
    String title;
    String author;

    Book(int bookid,String title,String author){
        this.bookid=bookid;
        this.title=title;
        this.author=author;
        }

    public void setBookId(int bookid){
        this.bookid=bookid;
    }
    public int getBookId(){
        return bookid;
    }
    public void setTitle(String title){
        this.title=title;
    }
    public String getTitle(){
        return title;
    }
    public void setAuthor(String author){
        this.author=author;
    }
    public String getAuthor(){
        return author;
    }
}
public class BookInformation{
    public static void main(String[]args){
        final ArrayList<Book> list=new ArrayList<Book>();

        list.add(new Book(1111,"Godan","Munshi Premchand"));
        list.add(new Book(2222,"My Experiment with Truth","Mahatma Gandhi"));
        list.add(new Book(3333,"Gitanjali","Rabindra Nath Tagore"));
        list.add(new Book(4444,"Malgudi Days","R K Naraynan"));
        list.add(new Book(5555,"Jayadev","GeetGovind"));

        JFrame f=new JFrame("Search");
        f.setLayout(null);
        JLabel label1=new JLabel("Enter book id ");
        final JLabel label2=new JLabel("Title ");
        final JLabel label3=new JLabel("Author ");
        final JTextField text1=new JTextField(20);
        final JTextField text2=new JTextField(20);
        final JTextField text3=new JTextField(20);
        JButton b=new JButton("Search");
        label1.setBounds(10,10,100,20);
        text1.setBounds(120,10,200,20);
        b.setBounds(350,10,100,20);
        label2.setBounds(10,40,100,20);
        text2.setBounds(120,40,200,20);
        label3.setBounds(10,70,100,20);
        text3.setBounds(120,70,200,20);
        label2.setVisible(false);
        text2.setVisible(false);
        label3.setVisible(false);
        text3.setVisible(false);

        b.addActionListener(new ActionListener(){
        public void actionPerformed(ActionEvent e){
        int ide=Integer.parseInt(text1.getText());
        if(!text1.getText().equals(" ")){
        label2.setVisible(true);
        text2.setVisible(true);
        label3.setVisible(true);
        text3.setVisible(true);
        for(Book data: list){
         if(data.getBookId()==ide){
         text2.setText(data.getTitle());
         text3.setText(data.getAuthor());
         }
         }
        }
        }
    });
        f.add(label1);
        f.add(text1);
        f.add(label2);
        f.add(text2);
        f.add(label3);
        f.add(text3);
        f.add(b);
        f.setVisible(true);
        f.setSize(500,200);
        }   
}

For more information, visit the following link:

http://www.roseindia.net/java/example/java/swing/addeditanddeleteemployee_inf.shtml









Related Tutorials/Questions & Answers:
searching for strings in a file
searching for strings in a file  how can i search of a person and display the other details associated with the name using java gui window?   import java.util.ArrayList; import javax.swing.*; import java.awt.event.
file searching
file searching  i need a prog for searching inside a text file after evry 1 min to find does it hav any new entry
Advertisements
searching inside a file for details
searching inside a file for details  i created a file with name,country,state etc...when i'm searching for the name, i have to get other details like country,state etc...please do help
Searching a word file on server in JSP - JSP-Servlet
Searching a word file on server in JSP  Seacrhing a word file on server side using JSP. I am Apache Tomcat Server. Please help me Sir
searching a text string in file - Java Beginners
searching a text string in file  code to match a string in a file that is already mentioned in java code.if the string matches any part of a string that whole string is printed
ModuleNotFoundError: No module named 'android-strings-file-converter'
ModuleNotFoundError: No module named 'android-strings-file-converter' ...: No module named 'android-strings-file-converter' How to remove the ModuleNotFoundError: No module named 'android-strings-file-converter' error
ModuleNotFoundError: No module named 'android-strings-file-converter'
ModuleNotFoundError: No module named 'android-strings-file-converter' ...: No module named 'android-strings-file-converter' How to remove the ModuleNotFoundError: No module named 'android-strings-file-converter' error
strings
strings  difference between the strings in java and c
strings
strings  write a program in java to accept two strings as command line arguments and perform the following operations-: 1) compare the strings 2... is an example which accept two strings as command line arguments and perform
strings
strings   read sentence and convert all the word into capital case like camelcase   Hi Friend, Try the following code: import java.util.*; class ConvertWordsIntoUpperCase { public static String toCamelCase(String
Strings
will contain strings which is separated by ",". From the main method invoke
searching books
searching books  how to write a code for searching books in a library through jsp
searching technique
searching technique  Hi, i need any searching technique in java to search the data and give the all possible data by links
searching problem
searching problem  how we can make a code in core java for searching in hard disk? i have to make an antivirus as my minor project , so i have need this type code to search the virus in hard disk
searching problem
searching problem  how we can make a code in core java for searching in hard disk? i have to make an antivirus as my minor project , so i have need this type code to search the virus in hard disk
searching string
searching string   how to write a program for searching a string   Hi Friend, Try this: import java.util.*; class SearchString{ public static void main(String[] args){ Scanner input=new Scanner(System.in
searching the data
searching the data  respected sir , i am making the desktop application , so how can i search the data which are stored in the mysql databses through click the button and display in jtable through netbeans dynamically
Sorting and Searching
); { System.out.println("Error reading from file"); } } } } System.out.print("Invalid
Java Sorting and Searching
Java Sorting and Searching   If anyone could help me with this I would be really thankful! Write a program that stores the names of these artists... introduced in the lecture and modify it so that it handles strings, rather than integers
Strings in PHP
Strings in PHP  Hi, I am beginners and want to know about strings in PHP and different ways to print a string. Can someone help me in this regards?   Following tutorials will help you in details about strings in PHP
strings concatnation
strings concatnation  in string1 "123456 ABC DEF...",IN string2 "raveen". iwant to add string2 after 123456 in the first string based on index number.i need logic
searching the string in a paragraph?
searching the string in a paragraph?  how to search a string in a paragraph and display the corresponding line number and position of a string in java
Searching for Code - JSP-Servlet
JSP, Servlet Searching for Code  Hi, i am looking for a jsp servlet code examples for the search function in my application.Thanks
strings in java
strings in java  please explain me the flow of this program..not able to execute correctly n wats the use of clone public class Strclone { public static void main(String args[]) { String s=new String("a"); String s1
strings 20june
strings 20june  please explain me the flow of this program..not able to execute correctly n wats the use of clone public class Strclone { public static void main(String args[]) { String s=new String("a"); String s1 = "Hello
searching from database
searching from database  how to search data from data base throug search...such as contact no./lastname /firstname should give whole information from database...   Please visit the following link: Servlet search
strings
strings
strings
strings
strings
strings
strings
strings
Strings
programes on strings
programes on strings   a. write a program to copy one array to another array using System.arrayCopy() method. b. write a program to check whether entered string is palindrome or not.   Have a look at the following link
Switch Statement with Strings in Java
Switch Statement with Strings in Java  Switch Statement with Strings in Java
Searching an element - JSP-Servlet
Searching an element  Dear sir, sir i have an employee... in that i am doing a searching an element by empId and displaying a all... field for searching an element by the empId.and one submit button for submitting
Searching an element - JSP-Servlet
Searching an element  Dear sir, sir i have an employee table... doing a searching an element by empId and displaying a all the employee table... for searching an element by the empId.and one submit button for submitting this form.And
Java String searching.
Java String searching.  How to search a string in given String array?   import java.util.Scanner; public class StringSearch { public... and for searching we used userCity.equalsIgnoreCase(city[i
Searching English words in a string
Searching English words in a string  My task is to find English words and separate them from a string with concatenated words..for example AhdgdjHOWAREgshshYOUshdhfh I need to find if there exists any English words.   
Searching operation in JAva
Searching operation in JAva  Sir, I have made a project for the Dispatch section of my office. I have to search for letters that are dispatched on a particular date. Now there are thousands of letters dispatched on a particular
Searching operation in JAva
Searching operation in JAva  Sir, I have made a project for the Dispatch section of my office. I have to search for letters that are dispatched on a particular date. Now there are thousands of letters dispatched on a particular
Searching operation in JAva
Searching operation in JAva  Sir, I have made a project for the Dispatch section of my office. I have to search for letters that are dispatched on a particular date. Now there are thousands of letters dispatched on a particular
Searching operation in JAva
Searching operation in JAva  Sir, I have made a project for the Dispatch section of my office. I have to search for letters that are dispatched on a particular date. Now there are thousands of letters dispatched on a particular
split strings in php
split strings in php  how can i split strings in word pair in PHP
ModuleNotFoundError: No module named 'strings'
ModuleNotFoundError: No module named 'strings'  Hi, My Python... 'strings' How to remove the ModuleNotFoundError: No module named 'strings... to install padas library. You can install strings python with following command
compare two strings in java
compare two strings in java  How to compare two strings in java...) { System.out.println("The two strings are the same."); } } } Output: The two strings are the same. Description:-Here is an example of comparing two
Finding searching phrase of a search engine
Finding searching phrase of a search engine  how to find out searching phrase of a search engine..? like, if visitors enter the keyword to google, is is any possible to get that keyword
Searching with alphabetical order - Java Beginners
Searching with alphabetical order  Hi, I want to this please help me Steps:- 1:-I have a one form of name text box with two button. 2:-user input in name text box(alphabetical order)search all fields from

Ads