DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 5 of 5
  1. #1
    Join Date
    Sep 2004

    Appending To TextBox, Unique Question?

    Okay this is what I want to happen but can't find anything on it.

    okay have a text box, User enters a name

    User Enters: John
    User Presses Enters, String John Goes to File

    User Enters: Jo
    I want the program to recognize the possibilities of what can come next,
    Is there some package or class that allows this to happen?

    Appending to a textbox

  2. #2
    Join Date
    Apr 2005
    Basically you are wanting to have the program search through previously entered data and append it into the boxes as selected? The functionality provided by say an addess bar in IE that has inline autocomple on?

    I don't know of anything that does this for you, but it shouldn't be too hard to implement yourself. Keep the data entered previously in some data structure, when the user starts typing have it search through the data structure and see if there are any matches to what the current text in the box is. If so append it in there and select the portion that was not enetered by the user. You will have to find out for yourself which events would be best to execute this in.

    Note that this could slow down your program somewhat, choosing your data structure carefully could help minimize load.

  3. #3
    Join Date
    Sep 2004
    Alright You understand what i"m tryin to explain, and my problem. Now what do you mean by a data structure, I think i'm still a little tech language inexperienced, I know what methods and constructors are, what's a data structure?

  4. #4
    Join Date
    Feb 2004
    A data structure is the method you use for storing the data. For example, an array is a data structure. For this problem you're going to need a data structure that is capable of storing words in some form or another and allows you to search quickly based on each letter that is entered. I imagine that some kind of tree structure where each node represents a letter would work well.

  5. #5
    Join Date
    Apr 2005
    What the previous poster said is corect, a data structure is something that hold multiple pieces of data.
    e.g. ArrayList

    The code below is by no means complete but should help you get on the right track, hope it helps

    ArrayList alTyped = new ArrayList();

    //In the event handler for lost focus or ActionEvent
    alTyped.add(jtfField.getText());//add what the user just typed

    //In Event handler for textfield change event or something like that, or keypressed, I'm not really sure which events you want to use
    String fieldText = jtfField.getText();
    for(int i = 0; i < alTyped.size(); i++)//traverse the ArrayList
    //do comparison here
    //for this comparison you will have to have another for loop
    //it will traverse the length of the String and compare, look at
    //look at String.regionMatches()

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
Latest Articles
Questions? Contact us.
Web Development
Latest Tips
Open Source

   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center

We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.