This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Searching  RSS feed

 
Jorah Espa�ol
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • 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


 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • 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
  • 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..
 
Jeanne Boyarsky
author & internet detective
Sheriff
Posts: 37222
519
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • Quote
  • Report post to moderator
nevermind!! I just fixed the problem.. thanks
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!