• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

Searching

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi!, I'm just new to java swing and jdbc... I'm the pace of searching records... I was making a code which can search for a record by typing a certain letter.. when I type 'j' all the letters that begins with 'j' appears etc. and I made it right..

here's the problem, I wanted to make a search which is better than that.. if I'm looking for a record example name: "john" when I type 'j' of course all the records that starts with 'j' will appear and then 'o' and all the records that starts with 'j' and has a second character 'o' will appear.. and so on... until it found "john"... I don't know how to make each character I type into one string...

can anybody correct my code or can give me any idea on how to make that.. hope to hear from all of you soon.. thanks


 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to JavaRanch.

I'm not sure what this has to do with JDBC (which is what this forum is all about), but if you want to accumulate the characters typed, something like this might do the trick:

Note that this doesn't handle the case where the user presses backspace, where you'd need to remove characters from the accumulated string. You'd also need to think about what should happen if the arrow keys or the mouse are used to position the insert cursor to someplace other than the very end of the input field.
 
Jorah Espa�ol
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi sir!!! it worked... wooohoooooo thanks for your reply... woohooooo I don't regret I joined this forum.. I hope I would learn lots from you thank you sooooooooooo much..
 
author & internet detective
Posts: 42134
937
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Jorah,
Welcome to JavaRanch!

Since this isn't about JDBC, I'm going to move it to our GUI forum.
 
Jorah Espa�ol
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
it's ok sir! sorry about posting in the wrong thread...

I still have a problem ... how can I make the string null again after I searched the record? coz it continues on adding all the characters I'm typing
 
Jorah Espa�ol
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
nevermind!! I just fixed the problem.. thanks
reply
    Bookmark Topic Watch Topic
  • New Topic