Help coderanch get a
new server
by contributing to the fundraiser
  • 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:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

sorting and filtering in jcombobox binded with database in netbeans

 
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hello...
i hava a problem in sorting and filtering in jcombobox binded with database in netbeans . i have done binding of this jcombobox with database table using netbeans.
that jcombobox contains department names in it. now i want to show this jcombobox data sorted in ascending order.
i also want autosuggestion in it.
for eg
Press "T" -> It will drop-down display everything beginning with "T"

Press "i" -> It will drop-down display everything that begins with "Ti"

Press "m" -> It will drop down display everything that has "Tim" at the beginning.

here is my code which i tried...

private void sort(){
ComboBoxModel Lmodel = comboDeprtmnt.getModel();
List list = new ArrayList<>();

for(int i= 0 ; i <comboDeprtmnt.getItemCount() ; i++)
{
String obj = (Lmodel.getElementAt(i).toString());
char[] arr = obj.toCharArray();
list.add(obj);
Arrays.sort(arr);
System.out.println(list);

Arrays.binarySearch(arr, c);
}

}

i get the character as...
char c;
private void comboDeprtmntKeyReleased(java.awt.event.KeyEvent evt) {
c= evt.getKeyChar();

}



please help i am new in java ...
any help will be appreciated.....
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic