how to use an editable combobox

how to use an editable combobox

Hello Everyone!!!!!!!! I have a jcombo box with certain values and i want to use it as an editable that means when user will type something in combobox, according to that text only matching item should appear in the list.

View Answers

June 20, 2012 at 11:44 AM

Here is an example of Editable JCombobox.

import java.sql.*;
import java.awt.*;
import java.util.*;
import javax.swing.*;
import java.awt.event.*;
class  EditableComboBox{

    public static void main(String[] args) throws Exception{
        JFrame f=new JFrame();
        f.setLayout(null);
        JLabel lab=new JLabel("Select");
        final JComboBox combo=new JComboBox();
        combo.addItem("Nano");
        combo.addItem("Alto");
        combo.addItem("Swift");
        combo.addItem("WagonR");
        combo.addItem("Scorpio");

        ActionListener actionListener = new ActionListener() {
      public void actionPerformed(ActionEvent actionEvent) {
        ItemSelectable is = (ItemSelectable)actionEvent.getSource();
        String name=selectedString(is);
        System.out.println("Selected: " + name);
        }
    };
       combo.addActionListener(actionListener);
       combo.setEditable(true);
        lab.setBounds(20,20,100,20);
        combo.setBounds(120,20,80,20);
        f.add(lab);
        f.add(combo);

        f.setVisible(true);
        f.setSize(300,120);
    }
    static private String selectedString(ItemSelectable is) {
    Object selected[] = is.getSelectedObjects();
    return ((selected.length == 0) ? "null" : (String)selected[0]);
  } 
}

For more information, visit the following link:

http://www.roseindia.net/java/example/java/swing/AddRemoveItemFromCombo.shtml









Related Tutorials/Questions & Answers:
how to use an editable combobox
how to use an editable combobox   Hello Everyone!!!!!!!! I have a jcombo box with certain values and i want to use it as an editable that means when user will type something in combobox, according to that text only matching item
editable combobox method selection
editable combobox method selection  how to make an editable combobox that shows nothing initially but as a key is pressed it pops up and selects an item starting with that letter, subsequent keys would keep sorting from the list
Advertisements
how can i display a editable result of form?
how can i display a editable result of form?  how can i display a editable result of form? i know how to display form result but the result... show the result but i can not modify the result. how can i display modifyable
how to select second combobox value .
how to select second combobox value .  I requirement is , i have two combo box, i am selected first combo box value then automatically second combo box value show ,But this both combo box value i retrieves in database. please
How to Connect J ComboBox with Databse - Java Beginners
How to Connect J ComboBox with Databse  How to Connect J ComboBox with Databse  Hi Friend, Do you want to get JComboBox values from database?Please clarify this. Thanks
how to maKE Jcombox editable after saveing value init.
how to maKE Jcombox editable after saveing value init.  i have one JCombobox with 2 values"y", "N".when i selecting some value from dropdown... the value and when i clicked on save unable to save it. how to maKE Jcombox editable
how to insert the selected item of combobox in mysql - XML
how to insert the selected item of combobox in mysql  hi, i have to insert the selected item from combobox into MYSQL database.pls provide... of combobox in mxml.how to insert selecteditem in database. pls suggest me i have
editable datagrid
editable datagrid  How to create a editable datagrid in jsp,struts1.3,glassfish v2.x application server and database oracle using netbeans6.8 ide.... ThanksADS_TO_REPLACE_2   thanks but i want a editable grid,with the option
Editable Html
Editable Html  i have editable html table with following elements textbox(n),checkbox(n),sno,dropdownlist..this elements are generated in runtime... how to take the values from the table and insert into database.please gimme some
How to insert data from a combobox and textbox values into DB using JSP?
How to insert data from a combobox and textbox values into DB using JSP?  hi, How to insert a comb-box and a text box values in to DB using JSP? @DB:student; @table:stu_info; Combobox values:(class1,class2,class3); textbox1
HOW TO DISPLAY ID IN TEXTBOX BASED ON COMBOBOX SELECTION IN A SAME PAGE
HOW TO DISPLAY ID IN TEXTBOX BASED ON COMBOBOX SELECTION IN A SAME PAGE ... createuser.jsp. There am loading this Rolename into combobox. My question is how to get Roleid in textbox when i select Role_name from combobox in a same
Flex ComboBox Component
Adobe Flex Combo Box Component: The ComboBox component of Flex is similar to the select option of HTML code. This component also has editable mode, in which a user can type on the top of the list. We use this component inside
ModuleNotFoundError: No module named 'sphinxcontrib-editable'
: No module named 'sphinxcontrib-editable' How to remove the ModuleNotFoundError: No module named 'sphinxcontrib-editable' error? Thanks   Hi...ModuleNotFoundError: No module named 'sphinxcontrib-editable'  Hi
comboBox validation
comboBox validation  dear sir. i want to know . how to validate radio button in struts using xml validation. thanks
How to declare a Combobox without using a string in its declaration?
How to declare a Combobox without using a string in its declaration?  What i mean to ask is how can i declare a combobox first and initialise... the examples and tutorials so far i haven't found any which tells me how to do
How to make addition of two combobox values using jsp and javascript?
addition of two combobox values using jsp and javascript  How to make addition of two combobox values using jsp and javascript?  <html> <h2>ComboBox</h2> <script language="javascript"> var arr
display uploaded file option in editable form
display uploaded file option in editable form  how to show the uploaded file in editable mode on the jsp in struts2.0
display uploaded file option in editable form
display uploaded file option in editable form  how to show the uploaded file in editable mode on the jsp in struts2.0
Non-edit Combobox with auto fill - Swing AWT
. I tried with ActionListener but no use :( . How can I detect the multiple...Non-edit Combobox with auto fill  Hi, I have a non-edit...-editable mode of JCombobox, For ex: If user type "Ch" JCombobox should select
how to retrieve data from database using combobox value without using request.getParameter in jsp - JSP-Servlet
how to retrieve data from database using combobox value without using request.getParameter in jsp  Answer pl
Java Swing dynamic Combobox
Java Swing dynamic Combobox In this section, you will learn how to display the data in one combobox related to another combobox. For this, we have created two combo boxes. In the first combobox, we have added four items. When the user
ModuleNotFoundError: No module named 'django-content_editable'
: No module named 'django-content_editable' How to remove the ModuleNotFoundError: No module named 'django-content_editable' error? Thanks   ...ModuleNotFoundError: No module named 'django-content_editable'  Hi
to jsp combobox exmple
to jsp combobox exmple  to jsp combobox exmple
Flex Combobox
Flex Combobox  flex combobox with database as dataprovider   You can visit the following link for detailed tutorial on the topic. May this will be helpful to you. http://www.roseindia.net/flex/flex-combo-box.shtml
ComboBox ItemRenderer in DataGrid
ComboBox ItemRenderer in DataGrid  Hi..... How can I create custom...}" variableRowHeight="true" editable="true" x="52" y...; <mx:ComboBox > <mx
how to output text from comboBox from first frame to textField on the second frame? please help me.. thank you in advance..
how to output text from comboBox from first frame to textField on the second frame? please help me.. thank you in advance..  how to output text from comboBox from first frame to textField on the second frame? please help me
Editable JTree
Editable JTree Nodes        In this section, you will learn  to make JTree editable..._TO_REPLACE_1 This program constructs a JTree that contains editable nodes. Firstly
ComboBox in Flex4
ComboBox in Flex4: In Flex4 Combobox is called a spark Combobox control. DropDownListBase control is the base class of the combobox control. Combobox control works like a DropDownList control. When we click on the combobox control
Flex Combobox
Flex Combobox  flex combobox with database as dataprovider  ... backgroundColor = '#CCCCFC' width = '100%' height = '100%'> <mx:ComboBox...; <mx:ComboBox x = '200' color = 'green'> <mx:dataProvider>
combobox
combobox
combobox
combobox
combobox
jsp combobox
jsp combobox  ihave three tables in database country,state and city..if i select one country throug combo box than other combobox show state only select country ...than city how i can implement through jsp   1
Combobox in HTML
the options in the list.ADS_TO_REPLACE_1 Here is how to make a simple Combobox...Combobox in HTML is used to display a drop-down list of some options from which one can be selected. <select> tag is supported in all the web browsers
Java swing: get selected value from combobox
Java swing: get selected value from combobox In this tutorial, you will learn how to get selected value from combobox. The combobox provides the list... of programming languages to the combobox using addItem() of JComboBox class. We have
How to display data fom MySQL DataBase-table in to JSP file by submitting a value in combobox.
How to display data fom MySQL DataBase-table in to JSP file by submitting a value in combobox.   I have the same problem.plz help me. I have MySQL DataBase/DB Name:lokesh; Table Name:TR_list; columns:nodename,packageno,TR
Non Editable Text File in java - Java Beginners
Non Editable Text File in java  Hello Sir ,I want to Show NonEditable TextFile on JButton Click which Contains User Manual of Project ,How I can Do It. plz Help Me
editable grid in jsp
editable grid in jsp  i want to create editable grid in jsp for invoice so that i can insert multiple product at a same time.how to create that in jsap, plz reply   We are providing you the code where we have specified
doubt in combobox in flex - XML
doubt in combobox in flex  hi, i have doudt in combobox... a combobox with 10 items when i select the particular item i has 2 display... friend, You can use selectedItem property or currentTarget property for getting
Java ComboBox in JOptionPane
Java ComboBox in JOptionPane In this section, you will learn how to create combo box in JOptionPane dialog box. We have created a button to perform an action.On clicking the button, you will get the dialog box with combo box in it. 
Problem With Combo Box Editable Property
Problem With Combo Box Editable Property  Hi I am new To Flex i had set Combo Box Editable Property as true. But I didn't get the property filtering in the combo box like when you enter text "S" in the combo box then the names
ModuleNotFoundError: No module named 'odoo10-addon-attachment-attach-non-editable'
-editable'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'odoo10-addon-attachment-attach-non-editable' How to remove the ModuleNotFoundError: No module named 'odoo10-addon
ModuleNotFoundError: No module named 'odoo10-addon-account-move-line-tax-editable'
-editable'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'odoo10-addon-account-move-line-tax-editable' How to remove the ModuleNotFoundError: No module named 'odoo10-addon
ModuleNotFoundError: No module named 'odoo10-addon-attachment-attach-non-editable'
-editable'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'odoo10-addon-attachment-attach-non-editable' How to remove the ModuleNotFoundError: No module named 'odoo10-addon
ModuleNotFoundError: No module named 'odoo11-addon-account-move-line-tax-editable'
-editable'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'odoo11-addon-account-move-line-tax-editable' How to remove the ModuleNotFoundError: No module named 'odoo11-addon
ModuleNotFoundError: No module named 'odoo12-addon-account-move-line-tax-editable'
-editable'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'odoo12-addon-account-move-line-tax-editable' How to remove the ModuleNotFoundError: No module named 'odoo12-addon
ModuleNotFoundError: No module named 'odoo12-addon-account-move-line-tax-editable'
-editable'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'odoo12-addon-account-move-line-tax-editable' How to remove the ModuleNotFoundError: No module named 'odoo12-addon
ModuleNotFoundError: No module named 'odoo13-addon-account-move-line-tax-editable'
-editable'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'odoo13-addon-account-move-line-tax-editable' How to remove the ModuleNotFoundError: No module named 'odoo13-addon

Ads