JSuggestField behaves like "Google Suggest", but you can use it in Java. It extends JTextField, adding special features. You can use it just like any other JComponent.
JSuggestField s = new JSuggestField(this, suggestData);
Archive contains the JSuggestField-class and an example. Tested with jre 1.6
» Download
|
version 0.5, 1. November 2011
new: define how jSuggestField matches inputs, case sensitivity and setHint() for displaying a 'type here' text
Licensed under the GLPv3 |

hi, rakudave..
i tried your sample it is really very good.
but the problem is that size of suggestion dialog (poped up)
can not set samll, i.e width is too much large .
how do i make it small.
help
Use one of the following:
public void setPreferredSuggestSize(Dimension size)
public void setMinimumSuggestSize(Dimension size)
public void setMaximumSuggestSize(Dimension size)
How about a SWT example?
hi,
One problem i'm facing in use of your suggestion field is that ,
I am making GUI from Netbeans IDE's drang nad drop , so not able to use this SuggestTextField from palllete.,
and you have created your own Textfield by extending JTextField..
how can i overcome this ..
Thanks :)
pls help..
I've never used NetBeans, I use Eclipse, so I probably can't help you...
hi, IDE is not a problem (either Eclipse or NetBeans).
my problem is 'm not able to use from mantissa pallet,like drag from pallet an place it on form (GUI).
need you reply.
Hi. I discover a bug, when you scroll down the combobox with cursor arrow keys.
Thanks, fixed
A very nice code that easily helps to achieve the task.. but waht about resizing.. Can anybody help me..
Use the setPreferred/Maximum/MinimumSize()-Functions
I can't use it inside a JDialog, since I have no JFrame there to relate it to - that's a pity!
You should be able to replace Frame by Window, and then it should work with a JDialog. It just needs some kind of top-container to attach the drop-down to...
Thanks a lot! Works perfectly now!
hello, can I set the suggestion box so it will only display maximum 10 items? thx anyway
sure, you can put a simple counter in the run-method of the InterruptableMatcher (located at the bottom of JSuggestField.java) and abort the loop as soon as your counter hits 10...
To display only the top N matches.
this code goes in method run() from the InterruptableMatcher:
... setFont(regular); maxSuggestions = new Vector();
int MAX_ITEMS_TO_SHOW = 10;
Vector
if (suggestions.size() > 0) {
if(suggestions.size() > MAX_ITEMS_TO_SHOW){
//Filter the top N items found
for(int i = 0; i < MAX_ITEMS_TO_SHOW; i++){
maxSuggestions.add(suggestions.get(i));
}
}else{
//Less than the max, add all the items to the new vector.
maxSuggestions.addAll(suggestions);
}
dataList.setListData(maxSuggestions);
dataList.setSelectedIndex(0);
...
HI rakudave,
I have added JSuggestField in an application but its not getting visible..... I have tried every possible way but in vain.....
can you send the code of the application you developed whose screenshot you have displayed above......
plz help,
thanks
open the .jar-file in an archive manager, the source classes are contained within
Thanks buddy !!!! Great job..
please help me
i have problem like this :
i write same word 'city' than JSuggestField drop down showing is :
city town
tokyo city
kyoto city etc
then i write same word 'green' than JSuggestField drop down is:
river green
green book
pc green etc
end then i won to show all like this :
i write 'city green' it's must like this to show :
city town
tokyo city
kyoto city
river green
green book
pc green
but can't show what wrong
please help me
Hey, Thanks, this component rocks!
great job my friend is very usefull this code i hope more people begin to share code like you grettings from urbe (universidad rafael belloso chacin) venezuela.
hi there. hideSuggest() method doesnt seem to work?
how can i hide the list of suggested items?
advanced thanks for help.
Hi, thanks for this component,
but,
at run time i am changing the suggestions,
the list is updated,
but display in dialog is not updated, how to fix??
works for me... (In the demo at least)
can you give me a more detailed description? Perhaps then I'll understand the problem...
Splendid! Thank you.
Besides one question: if field is empty on lost focus event content is replaced with "Type a variable name here...". How to get rid of this?
Yeah sorry this is hard-coded :-/ You'll have to change the source
(I'll try to provide a method for that in the future)
how do i change the size of the popup window of names that appears to 25
Use one of the following:
public void setPreferredSuggestSize(Dimension size)
public void setMinimumSuggestSize(Dimension size)
public void setMaximumSuggestSize(Dimension size)
... but I'm not sure what you mean with "appears to 25"
You rocked man
Gr8 Job Friend........
Hi. I have a question. I saw that you have there 3 methods for redimensioning the JSuggestField, and i tried something like this:
Dimension d= new Dimension(10,10);
s.setMaximumSuggestSize(d);
but it does not work. I even tried on your example and it doesn't work. Any idea why?
Hi,as i am new to java,I don't know how to use this JSuggestField in my Netbeans project.Can anyone suggest me a sample code showing how and where to add this or apply this?
JSuggestField couldnt use on NetBeans normaly like another custom components.
I use it by do some trick
1. drag a JTextField on your form
2. right click on this and choose customize code
3. In initialization code, chose custom creation instead default
4. edit like that
tf_searchStudent = new javax.swing.JTextField()
=> tf_searchStudent = new JSuggestField(new Frame())
5. You look down and see another field for initialization and edit like that , too); method
private javax.swing.JTextField tf_searchStudent;
=>
/*
private javax.swing.JTextField tf_searchStudent;
*/
private JSuggestField tf_searchStudent;
6. Get some data by use setSuggestData(Vector
hi rakudave, can you put some method to change a string "Type a variable name here..." ??
thank
Hello. I have a problem with this code. I have a program which adds some customers into the database. I have 2 fields of type suggestfield. When I insert the data in the fields everything works perfectly. When I press ok (ok means add data to database and set fields to be not editable), all my fields are emptied(program is supposed ), but the suggestion dialog is opened, without positioning the mouse over the field. And hideSuggest method does not work. Do you know why it does that?
Sounds like a bug. I'll have to do some refactoring anyway, I'll have a look at it. (I'm kinda busy right now, might take awhile...)