wood burning stoves 2.0*
The moose likes Swing / AWT / SWT and the fly likes Searching keywords in texpads Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Searching keywords in texpads" Watch "Searching keywords in texpads" New topic
Author

Searching keywords in texpads

Cyrone Gerella
Greenhorn

Joined: Oct 06, 2013
Posts: 2
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



[Thumbnail for untitled.JPG]

Richard Tookey
Ranch Hand

Joined: Aug 27, 2012
Posts: 1044
    
  10

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

Joined: Oct 06, 2013
Posts: 2
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
Ranch Hand

Joined: Aug 27, 2012
Posts: 1044
    
  10

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

Joined: Jun 13, 2009
Posts: 2179
    
    7
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Searching keywords in texpads