How to use Auto Complete Source in Combo Box using Java Tutorial

How to use Auto Complete Source in Combo Box using Java Tutorial

This tutorial is all about How to How to use Auto Complete Source in Combo Box using Java Tutorial. In this tutorial you will learn How to use Auto Complete Source in Combo Box using Java Tutorial. Auto Complete Source in Combo Box using Java Tutorial will make your combo box more user friendly. And it allows the user to search an item inside combo box values. When you type something like for example you type the letter R all the items that start with the R are going to be display. This tutorial uses swingx-all-1.6.4.jar and swingx-all-1.6.3.jar version Package library, one combo box components and NetBeans IDE. Please follow all the steps below to complete this tutorial.

How to use Auto Complete Source in Combo Box using Java Tutorial steps

 

Download the swingx-all-1.6.4.jar and swingx-all-1.6.3.jar package in this website

http://www.java2s.com/Code/Jar/s/Downloadswingxcore162AutoCompletitionjar.htm

 

 

If the download is done, add it to your project by right clicking the Libraries folder located in your project and then Add JAR/Folder and browse where your downloaded package located and inside lib folder add these two libraries.

The next step is to

Create your project by clicking file at the top of your project and then click new project, you can name your project whatever you want. Create you form by right clicking the Source Packages and by selecting New JFrame Form and then drag a Combo box in your form.

After that you need to import these packages

import org.jdesktop.swingx.autocomplete.AutoCompleteDecorator;

above your class and

then double click your button and copy paste the code below:

the code below is how you can populate your database values in combo box

[java]

try {

String sql = “SELECT product_name FROM products”;

pst = conn.prepareStatement(sql);

rs = pst.executeQuery();

while(rs.next()){

productsCombo.addItem(rs.getString(“product_name”));

}

}catch(Exception e){

JOptionPane.showMessageDialog(null, e);

}

[ /java]

This line of code “ AutoCompleteDecorator.decorate(productsCombo); ” is what make the auto complete source works.

Then you’re done. Run your project and see if it works.

About How to use Auto Complete Source in Combo Box In Java

Project Name: How to use Auto Complete Source in Combo Box
Language/s Used: JAVA
Database: MySQL
Type: Desktop Application
Developer: IT SOURCECODE
Updates: 0
How to use Auto Complete Source in Combo Box In Java– Project Information

For questions or any other concerns or thesis/capstone creation with documentation, you can contact me through the following:

E-Mail: [email protected]

Facebook: facebook.com/RyyanSalem

Contact No.: +639098911050

Ryan A. Salem

BSIT Graduate, soon to be MIT.

Java Developer / System Developer

Related topic(s) that you make like:

1.) Delete Confirmation Dialog using Java Tutorial in Netbeans IDE
2.) Automated Voting System using Java in Netbeans IDE

Leave a Comment