im currently creating a JTextField that will be able to auto suggest words that are existing inside a vector..
i currently have this..
now im getting problems on checking if the currently entered characters would match anything inside the vector..
as you can see, i used the contains() method on vector. but it only checks for whole words.
i want to check if a certain object inside the vector somehow starts with the currently typed string.
i have an idea about using contains() with startsWith() but i dont have any idea how to do it..
Class String wrote:Returns true if this vector contains the specified element. More formally, returns true if and only if this vector contains at least one element e such that (o==null ? e==null : o.equals(e)).
So one solution is to create a class called for example, Phrase. This class would have a member variable of type String that contains the phrase entered by the user. Instead of adding Strings to the Vector, add Phrase instances. Override the equals() method of the Phrase class and return true if the input String is in the member variable String. Please respond if you need further clarification.
Aron Jhed Amiscosa
posted 9 years ago
taking Mr. Prime's suggestion, i have come up to this..
i believe its working fine. now, im to put the suggested words to the text field and highlight the remainder of the currently possible matching word.
can you please guide me with that? thanks a lot.
Hey! You're stepping on my hand! Help me tiny ad!
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop