Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Java-Beginners how to use an editable combobox
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


Vishal Dhole
how to use an editable combobox
1 Answer(s)      2 years and 4 months ago
Posted in : Java Beginners


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.


Advertisement
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 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 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
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...;thanks but i want a editable grid,with the option of modify and delete
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 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
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
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
comboBox validation
comboBox validation  dear sir. i want to know . how to validate radio button in struts using xml validation. thanks
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
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
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
Editable JTree
Editable JTree Nodes        In this section, you will learn  to make JTree editable...: This program constructs a JTree that contains editable nodes. Firstly, it defines
How to use Servlet and Ajax?
How to use Servlet and Ajax?  How to use Servlet and Ajax
how to use calender in php
how to use calender in php  how to put calender in php
How to use AT Commands with J2ME?
How to use AT Commands with J2ME?  How to use AT Commands with J2ME? Thank you for your answer
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
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
how to use mouse pressed
how to use mouse pressed   to action mouse clicked
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
how to use button in array
how to use button in array  plz tell me how to code for button in array
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
ComboBox ItemRenderer in DataGrid
ComboBox ItemRenderer in DataGrid  Hi..... How can I create custom...}" variableRowHeight="true" editable="true" x="52" y="31...; <mx:ComboBox > <mx:dataProvider>
Advertisements
 

 

 

DMCA.com