• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Searching keywords in texpads

 
Cyrone Gerella
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to do a program that searches a keyword on a textpad, and displays it Alphabetically,
can somebody help me in here?




This is the content of the Textpad "books.txt" :
BK0001#Introduction to IT#Yoko Ono#RoseIndia Inc.#2000
BK0002#Advanced C-Programming#John Lenon#Princeton Hall#2003
BK0003#VB.Net 2005#Paul McCartney#Microsoft Publishing#2005
BK0004#Programming for Dummies#George Harrison#Microsoft Publishing#2005
BK0005#J2ME#George Harrison#PUB003#2010
BK0006#Android Development#John Lenon#Microsoft Publishing#2011
untitled.JPG
[Thumbnail for untitled.JPG]
This is what the GUI looks like
 
Richard Tookey
Bartender
Posts: 1166
17
Java Linux Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Cyrone Gerella wrote:
I want to do a program that searches a keyword on a textpad and displays it

There are many algorithms for efficient searching; 3 that come to mind are Knuth-Morris-Pratt, Boyer Moore and Rabin-Karp. Google is your friend.

As to displaying the word, you don't say how you want it displayed.

Alphabetically can somebody help me in here?


I don't understand the concept of 'alphabetical help' and if you mean you want to display the found words in an alphabetical list then this does not make sense since you are only searching for a single word.

Looks to me like you need to sit down with a pen and paper and write down and sketch what you want to achieve.
 
Cyrone Gerella
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Richard Tookey wrote:
Cyrone Gerella wrote:
I want to do a program that searches a keyword on a textpad and displays it

There are many algorithms for efficient searching; 3 that come to mind are Knuth-Morris-Pratt, Boyer Moore and Rabin-Karp. Google is your friend.

As to displaying the word, you don't say how you want it displayed.

Alphabetically can somebody help me in here?


I don't understand the concept of 'alphabetical help' and if you mean you want to display the found words in an alphabetical list then this does not make sense since you are only searching for a single word.

Looks to me like you need to sit down with a pen and paper and write down and sketch what you want to achieve.




I want to display the texts on the textpads alphabetically

like, the book with letter A displays first ... and so on...
 
Richard Tookey
Bartender
Posts: 1166
17
Java Linux Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Cyrone Gerella wrote:
I want to display the texts on the textpads alphabetically

like, the book with letter A displays first ... and so on...


Sorry but you have lost me! What has that to do with searching for key words?

One approach to sorting the content load the lines into an array or List and to sort the lines using Arrays.sort() if you decide to use an array and Collections.sort() if you decide to us a List. You will need to define a comparator that decides which of two lines should come first in the display. Check the Javadoc for details.
 
Rob Camick
Ranch Hand
Posts: 2613
9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would suggest you store and display all the data in a JTable. A JTable will allow you to sort and filter the data in the table by column.

Read the Swing tutorial on How to Use Tables, especially the section on Sorting and Filtering for a working example that will help with filtering.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic