Combobox dropdown functionality

Hi,
I have a combobox dropdown for a Column in my table. it displays "codes Description" something like this
01 Apparel
02 Houseware
03 Kitchenware
I have a query to get this data in the dropdown from a oracle table.
Select LEVEL1_CATEGORY_CD, CATEGORY_DESC From PRODUCT_CATEGORY1
Order By PRODUCT_CATEGORY1.CATEGORY_DESC
I am using setboundsql() method of the Column class in Quicktable.
http://quicktable.org/doc/quick/dbtable/Column.html
I have also tried getting the query data in a hastable as a key/value pair and fill the combo box.
what i need is when user selects something from the dropdown like "02 Houseware" i need only 02 to be filled into my cell. is this possible? right now its filling "02 Houseware" in the dropdown. can you explain stepwise as i am new to swing API.
Thanks.

I guess I am close but doing something silly. thats how I learn.
here is my code snippet,
final JComboBox comboBox;
         comboBox = new JComboBox( model );   // model.addElement(rs.getString(1));
         comboBox.setEditable(true);
         comboBox.setSelectedIndex(-1);
      comboBox.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent evt) {
     if (comboBox.getSelectedIndex()==-1) return;
     String s= comboBox.getSelectedItem().toString().trim();
    comboBox.setSelectedItem(s.substring(0,2));
      c.setCellEditor(new DefaultCellEditor(comboBox));   //c = dBTable1.getColumn(1);My vector has elements like, "01 Apparel".
I am able to get these in the dropdown. when i select something, its filling, 01 Apparel . after selecting if i click the cell again, then its changing to 01(as i needed). else after selecting if i lose focus and go to other cell, the value remains as 01 Apparel.
this might be trivial for someone who knows Swing but I am gettting frustrated...have to read complete tutorial this weeknd :)
Thanks again.

Similar Messages

  • ComboBox (dropdown) Need Help Adding URL links!!!

    I am somewhat of a newbie....Anybody know how to use URL
    links in a ComboBox dropdown menu? NEED HELP!!!!!!! I'm trying to
    make it so that after selecting an option, the user is directed to
    another URL within the same browser window. Using flash 8!
    Thanks,

    Im a bit a newbie myslef but i think you make flash
    commuincate to javascript wich will make the browser goto the URL.
    do a search on getURL and javascript together and i am sure
    you will find something.
    And when slecting to redirct i think its on?(onPress)
    something so maybe look throught the help section in flash 8 and
    look at componets. I think there is some actionscript help there.
    Sorry i could not be more helpful.

  • Combobox dropdown height

    Hi,
         Anybody know, how to increase the cell height of a combobox dropdown.
    Thanks in advance.

    Search more on Custom cell renders you will get your answer.
    The process is create your own cell renderer then set it as cell renderer for combobox and use it.
    For more info visit: http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/fl/controls/listClasses/CellRend erer.html

  • Combobox dropdown doesn't refresh

    Hi all!
    I have a comboBox problem. Please test this simple code:
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical"
        creationComplete="init()">
        <mx:Script>
            <![CDATA[
                import mx.collections.ArrayCollection;
                [Bindable]
                private var dp:ArrayCollection;
                private function init():void
                    dp = new ArrayCollection(["one", "two"]);
            ]]>
        </mx:Script>
        <mx:ComboBox id="cb" dataProvider="{dp}"/>
        <mx:Button label="click me" click="dp = new ArrayCollection(['three', 'four']);dp.refresh()"/>
    </mx:Application>
    What happens is that the dropdown list of the combobox doesn't show the new values. I guess I'm overlooking something here.
    Any advice?
    Thanks!
    Dany

    Hi Archimedia,
    I have run the sample code that you have sent....but I could see no problem I could see the combobox being refreshed when the button being clicked.
    However it is always safer to remove all the elements in the ArrayCollection using the removeAll() method before assigning the new values.
    Try the below code and check whether it's working for you...?
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application 
    xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" creationComplete="init()"
    >
    <mx:Script>
    <![CDATA[
    import mx.collections.ArrayCollection; 
    Bindable] 
    private var dp:ArrayCollection; 
    private function init():void
    dp =
    new ArrayCollection(["one", "two"]);}
    private function refreshComboBox():void
    if(dp != null){
    dp.removeAll();
    dp.refresh();
    dp =
    new ArrayCollection(['three', 'four']);}
    ]]>
    </mx:Script>
    <mx:ComboBox id="cb" dataProvider="{dp}"/>
    <mx:Button label="click me" click="refreshComboBox()"/></mx:Application>
    If this post answers your question or helps, please kindly mark it as such.
    Thanks,
    Bhasker Chari

  • How do I limit typing in a ComboBox Dropdown list

    I’ve created a form and added a ComboBox which generated the code:
    this->DateList = (gcnew System::Windows::Forms::ComboBox());
    this->SuspendLayout();
    // DateList
    this->DateList->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 12,
    System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point,
    static_cast<System::Byte>(0)));
    this->DateList->FormattingEnabled = true;
    this->DateList->Location = System::Drawing::Point(91, 7);
    this->DateList->Name = L"DateList";
    this->DateList->Size = System::Drawing::Size(121, 28);
    this->DateList->TabIndex = 0;
    this->DateList->SelectedIndexChanged += gcnew System::EventHandler(this,&Form1::DateList_SelectedIndexChanged);
    And then I added some custom code to add the items to the DateList
    for ( int x = numSnapShots - 1 ; x >= 0 ; x-- )
      String ^ item = gcnew String ( SnapShots[x]->dateStr );
        this->DateList->Items->Add(item);
    this->DateList->SelectedIndex = 0;
    All is working fine, I can select any Snapshot date I want from the list. 
    The problem is that I can also type anything I want in the ComboBox. 
    The dropdown of 12/31/2014 is in the list, but I can also type “Last Year” and of course the code doesn’t know how to handle that.
    What item in the combobox do I have the change to what to disable the user’s ability to type in the combobox?

    David,
    Maybe I didn’t look hard enough, but I could not find a way to create a C# WinForms project and include my existing C++ code as is and then interface the form front end to the existing C++ logic.
    I did find relatively easy ways for a C++ CLI Windows Forms Application to communicate with standard C++. 
    I had to limit the data types that I passed pack and forth, but the link up was relatively easy.
    I have externals in Form1.h which can then simply call the primary C++ interface:
    extern std::string str;
    extern std::string strPage;
    extern std::string strDate;
    extern
    void Initialize();
    extern
    int RebuildPage(int);
    Initialize() is called right after Initialize Component() to load all the data into memory and build the first HTML page.
    if (RebuildPage(7))    
    RefreshThePage();
    Exists for most of the button clicks and dropdown selections. 
    The number tells the C++ code what form control was clicked and a nonzero return tells the form to refresh the page. 
    Refresh the page is a simple Form1.h method that does just that, changes the labels on the form header and refreshes the HTML string to the new HTML data created by the C++ logic.
    void RefreshThePage(void)
    this->webBrowser1->DocumentText =
    gcnew String( str.c_str() );
    this->ViewLabel->Text =
    gcnew String( strPage.c_str() );
    this->DateLabel->Text =
    gcnew String( strDate.c_str() );
    This allowed me to perform all of the complex operation in the existing code with minimal changes, like changing the fprintf’s that created the original HTML files into str.append logic to pass the pages directly to the form.
    It’s true that all of my other code was batch style console applications, but the form front end was not totally difficult to learn and the simple fixes like David Lowndes just suggested makes the coding even easier. 
    Thanks again Dave.
    I created a very complex program to make visualizing mutual fund trends very simple. 
    The problem with the batch console application was that if I wanted to stop highlighting symbol ABC and wanted to start highlighting XYZ, I had to modify a data file by hand and then rerun the batch process to recreate the entire website on my local
    drive so I could not instantly see the change.  Using a form front end and building and displaying the pages interactively make that process instant.

  • How to display a combobox(dropdown menu) in a jsp page?

    Hi friends,
    I need to create a jsp page which contains three text fields and a single dropdown menu,,, . and my functionality is while loading the page itself that dropdown menu gets the data from database and holds in it..... i mean the data in theat combo box must gets from Database and based on the particular selection the remaing fields has to be filled ...... so plz helpme to solv this and any help is appriciated....
    regards
    priya......

    Hi,
    Google should definitely help you with this. I am sure that there may be people here who will guide you through each step in this forum. But, you learn only when you do things yourself. Please take some time to go through the links in google. You will definitely find all the things required to solve your problem.
    1) JDBC examples to populate your dropdown.
    2) DHTML+Javascript to handle selection/display of fields.
    You can come here for help only after you have tried to some extent and not able to proceed with something. Trust me, you should be able to do it yourself.
    Karthik.

  • Combobox dropdown menu bug in FlashPlayer 10

    Hello,
    I discovered that the combobox drop down menu do not drop UP
    in fullscreen with a screen format 16/10.
    Could you confirm ?
    See sample on
    http://gdfsuez.visitonweb.com/flash/awirs.html
    Regards,
    Dimitri

    Hi,
    Google should definitely help you with this. I am sure that there may be people here who will guide you through each step in this forum. But, you learn only when you do things yourself. Please take some time to go through the links in google. You will definitely find all the things required to solve your problem.
    1) JDBC examples to populate your dropdown.
    2) DHTML+Javascript to handle selection/display of fields.
    You can come here for help only after you have tried to some extent and not able to proceed with something. Trust me, you should be able to do it yourself.
    Karthik.

  • Combobox dropdown closes when refreshing dataprovider

    Hi,
    i'm having a small problem when filtering a dataprovider of a
    combobox and then refresh it.
    When the dropdown is open before the refresh() call, it'll
    close itself when refreshing the dataprovider.
    I've tried overriding the close() method but close() doesn't
    get called during this close operation.
    Also, the close event is not dispatched.
    Anyone knows if it's possible to prevent the dropdown from
    closing ?

    I don't think its possible, because the items in the list
    could completely change and it needs to close so it can remove the
    old lists and add the new items.
    You couldn't hold me to that thought its just my
    guess.

  • ComboBox [type Function] XML problem

    What I'm trying to accomplish is populating a ComboBox
    component's labels and data using an Array that's created from an
    XML data source. I know that I can populate the ComboBox in
    ActionScript using this:
    comboBox.labels = ["itemA",'itemB","itemC"];
    -OR-
    var cbArray:Array = ["itemA",'itemB","itemC"];
    comboBox.labels = cbArray;
    However, I'm running into problems when the Array is created
    from my XML datasource, like this:
    for (var g:Number = 0; g < aChildren.length; g++) {
    var aItem:String = aChildren[g].firstChild.firstChild;
    cbArray.push(aItem);
    comboBox.labels = cbArray;
    trace(cbArray);
    I've left all of the XML details (load, onload, etc.) because
    I don't think that the problem is there. In my example, when I test
    the movie, the trace(); function displays the correct info, but the
    comboBox component is populated only with an identical number of
    instances:
    [type Function],[type Function],[type Function],[type
    Function],[type Function]...
    I couldn't find a thread anywhere with my particular problem.
    Any ideas?

    I'm answering my own question. Hopefully someone will still
    benefit from it being here. Someone I work with is a JavaScript
    guru type and he worked through this with me. For some reason, the
    aItem variable isn't being perceived as a string. So, the solution
    I found was to alter the code here:
    var aItem:String =
    aChildren[g].firstChild.firstChild.toString();
    This fixed my problem.

  • ComboBox / DropDown with UIX

    Hello People,
    I'm bulding an application using Business Components and UIX JSP for BC, how can I put a ComboBox or a DropDown Control that contains all the information of an attribute of a table.
    regards

    >
    I use the messageChoice element and works fine for me. But for it works we must to define the bc4j:viewObjectDef element into bc4j:registryDef element, is it correct?
    Yes, you do need the viewObjectDef in the registryDef.
    >
    Well, if it is, we must to put two parameters into bc4j:registryDef element that are the name of the view and the rangeSize of the view. The rangeSize determines the amount of records to fetch, is it correct? If it is, how can I fetch all records?
    I believe that the rangeSize parameter is optional and that omitting it means "return me all rows". Try leaving it off and see if that returns everything.
    -brian
    Team UIX

  • How to create an own dropdown function in the ALV toolbar?

    Dear experts,
    I follow the sap.help.com and try to create a dropdow as an own fucntion the the toolbar of an ALV.
    My codes are as following:
    DATA:  lo_dropdown TYPE REF TO CL_SALV_WD_FE_DROPDOWN_BY_IDX,
                lo_dropdown_func  TYPE REF TO CL_SALV_WD_FUNCTION
                lo_value  TYPE REF TO  CL_SALV_WD_CONFIG_TABLE.
    lo_value = ir_interface_controller->get_model( ).
    CREATE OBJECT lo_dropdown EXPORTING texts_elementname = 'DROPDOWN'.
    lo_dropdown_func = lo_value->if_salv_wd_function_settings~create_function( id = 'DROPDOWN' ).
    lo_dropdown_func->set_editor(  lo_dropdown ).
    lo_dropdown->set_enabled.
    I also set an external Context-Mapping to the Context-node FUNCTION_ELEMENTS of ALV-Interfacecontroller.
    But now I get an error message "The ASSERT condition was violated"
    The error position has the following code and comments:
    " Context Path contains no multiple node
         assert 1 = 2
    Could you please tell me, how could I fix this bug?
    Thanks a lot!
    Regards,
    meer

    >** " Context Path contains no multiple node
    From this statement I'm guessing that the context node that the DropDownByIndex editor is bound to isn't a multiple node (1:n or 0:n).  A byIndex gets its allowed values in the drop down from the elements in a context node. Therefore it doesn't make sense to bind a byIndex to a 0:1 or 1:1 context node.

  • AE 5.2: Using user groups as a dropdown function

    Hi All
    We would like to use the user group functionality on CUP but the client does not have the same user groups across all systems.
    Our suggestion is that they have all user groups defined across all the systems.
    Is there a way that we could accomodate the client as per the current set-up where not all user groups are defined on all systems?
    Any assistance on this matter will be appreciated.

    Hi,
    I'm not sure of all the complexities around this but we had a similar problem where the user respository we used could not be connected using LDAP.
    The solution that was implemented was to create an ADAM (Active Directory Application Mode) directory, which is connected to the user repository - ADAM is then connected the UME for AE as the LDAP server.
    Probably not the most elegant solution, but we have been using this in  PRD environment for a couple of months now without any performance issues.
    Unfortunately I don't have all the details to guide you through all the config that was required, but perhaps you could investigate this as an alternative solution.
    Regards

  • How edit a combobox class for dropdown direction changing?

    hi all,
         i wanna change the direction of combobox dropdown so How can i edit a combobox class for dropdown direction changing?

    Someone gave me a class file to put into my applet.
    ... Does anyone know how to go
    into the class file and change it? And why can't you ask "someone" for the source? Or ask them to modify it for you?

  • Custom Font On Individual Row Items In A ComboBox Component

    Hello everyone,
    I am new to flash and I have spent many hours trying to get a
    particular piece of functionality to work. I am trying to create a
    combobox where the items listed in the combobox are font names and
    each item will display using the font of the item label. For
    instance, one item label in the list is "New Times Roman" and I
    want that particular row in the combobox to have the text AND font
    of "New Times Roman". For some reason, inside of my custom
    CellRenderer class, I cannot seem to find a way to get the item
    label that corresponds to the CellRenderer and the
    CellRenderer.data item always appears to be null!
    Please help. Thank you in advance for any help you can
    provide.
    This is the code I am currently using:
    //From the main class, I am creating an instance of the
    CustomizableComboBox and adding in the font names I am interested
    in.
    var comboFont:CustomizableComboBox=new
    CustomizableComboBox();
    comboFont.width=200;
    comboFont.height=30;
    comboFont.addItem({label:"Arial", data:"Arial"});
    comboFont.addItem({label:"Times New Roman", data:"Times New
    Roman"});
    comboFont.addItem({label:"Tahoma", data:"Tahoma"});
    comboFont.addItem({label:"Verda", data:"Verda"});
    comboFont.addItem({label:"Wide Latin", data:"Wide Latin"});
    comboFont.addItem({label:"Monotype Corsiva", data:"Monotype
    Corsiva"});
    comboFont.addItem({label:"Trebuchet MS", data:"Trebuchet
    MS"});
    comboFont.addItem({label:"Alba", data:"Alba"});
    comboFont.addItem({label:"Arial Black", data:"Arial Black"});
    comboFont.selectedIndex=1;//Times New Roman by default.
    addChild(comboFont);
    //In the CustomComboBox.as file, I have the CustomComboBox
    class defined as:
    package {
    import fl.controls.ComboBox;
    import flash.text.TextFormat;
    import flash.events.Event;
    public class CustomizableComboBox extends ComboBox{
    public function CustomizableComboBox(){
    super();
    dropdown.setStyle("cellRenderer",CustomCellRenderer);
    addEventListener(Event.CHANGE,changeIndex);
    //Changes the text displayed as the currently selected item
    with its corresponding font.
    private function changeIndex(event:Event):void {
    var fontName:String=selectedItem.label;
    var format:TextFormat=new TextFormat(fontName,16);
    setStyle("textFormat",format);
    //Finally, in the CustomCellRederer.as file, I have defined
    the CustomCellRenderer class as:
    package{
    import fl.controls.listClasses.CellRenderer;
    import flash.text.TextFormat;
    import fl.controls.ComboBox;
    public class CustomCellRenderer extends CellRenderer{
    public function CustomCellRenderer(){
    //The trace will show that the data for the custom
    cellrenderer is always null!!!
    trace('custom cell data = '+data);
    //If I could just get the item label corresponding to the
    CellRenderer for this
    //cell, then I could set the font as I desire.
    var fontName:String="Wide Latin";
    var format:TextFormat = new TextFormat(fontName,16);
    setStyle("textFormat", format);
    }

    Oh, sorry. I see now what you want to do. Hmmm...
    I cannot find any references to the class that defines each
    item in the box. Off the top of my head what I would do (besides
    writing my own combobox :-) - I would add some event listener with
    capture set to true that would listen to the input text field
    change Event.CHANGE and set ComboBox.editable = true. So, when you
    type something in the item - it will dispatch event. By reading
    Event.target, you may figure out what object is the TextField you
    want to chage the style for. After that it may be possible just to
    change style for each individual item's TextField.
    myComboBox.editable = true;
    myComboBox.addEventListener(Event.CHANGE, changeHandler);
    private function changeHandler(e:Event):void{
    trace(e.target + " : " + e.currentTarget);
    Just a thought...

  • In combobox 'g' is getting cut off, 'g' is not fully visible

    Hi Flex people,
    I am facing problem in combobox, I have the items : 'moon' , 'manager' , 'marketing' in the combobox.
    The text 'moon' is fully visible, but the in text 'manager' , 'g' is cut off, means character 'g' is not fully visible.
    Please give solution to how to make the 'g' to visible in  the selected item of combobox.
    Please find the attached snapshot, that will give clear idea.
    Thanks,
    Sushant

    Try this component:
    <?xml version="1.0" encoding="utf-8"?>
    <mx:ComboBox xmlns:mx="http://www.adobe.com/2006/mxml" creationComplete="init();" updateComplete="adjustComboDropDownWidth();"
        buttonMode="true">
        <mx:Script>
        <![CDATA[
            import mx.controls.List;
             private var _selectedValue:String;
             private var _selectedLable:String;
             private var bSelectedValueSet:Boolean = false;
             private var bDataProviderSet:Boolean = false;
             [Bindable]
                private var myDropdownFactory:ClassFactory;   
             // Override committ, this may be called repeatedly
             override protected function commitProperties():void
                // invoke ComboBox version
                super.commitProperties();
                // If value set and have dataProvider
                if (bSelectedValueSet && bDataProviderSet)
                   // Set flag to false so code won't be called until selectedValue is set again
                   bSelectedValueSet=false;
                   // Loop through dataProvider
                   for (var i:int=0;i<this.dataProvider.length;i++)
                      // Get this item's data
                      var item:String = this.dataProvider[i].data;
                      // Check if is selectedValue
                      if(item == _selectedValue)
                         // Yes, set selectedIndex
                         this.selectedIndex = i;
                         break;
             // Trap dataProvider being set
             override public function set dataProvider(o:Object):void
                // invoke ComboBox version
                super.dataProvider = o;
                // This may get called before dataProvider is set, so make sure not null and has entries
                if (o!=null && o.length)
                   // Got it, set flag
                   bDataProviderSet = true;
             // set for selectedValue
             public function set selectedValue(s:String):void
                // Set flag
                bSelectedValueSet = true;
                // Save value
                _selectedValue = s;
                // Invalidate to force commit
                invalidateProperties();
              * @author       : Prashant Shelke.
              * @date         : 17/10/07
              * @method name : init()
              * @i/p params  : -
              * @return            : void
              * @description : To show tool-tip on line items objects of combobox.
              public function init():void
                    myDropdownFactory         = new ClassFactory(List);
                    myDropdownFactory.properties = {showDataTips:true, dataTipFunction:myDataTipFunction}
                    this.dropdownFactory    = myDropdownFactory;
                 private function myDataTipFunction(value:Object):String
                    return (value.label);
               * @author       : Prashant Shelke.
              * @date         : 17/10/07
              * @method name : adjustComboDropDownWidth()
              * @i/p params  : ComboBox
              * @return         : Number
              * @description : computes dropdown width according to what dataprovider provided to it.
              private function adjustComboDropDownWidth():void
                      this.dropdownWidth    = calculateCustomPreferredSizeFromData();                  
              * @author       : Prashant Shelke.
              * @date         : 16/10/07
              * @method name : calculateCustomPreferredSizeFromData()
              * @i/p params  : -
              * @return            : Number
              * @description : computes dropdown width according to what dataprovider provided to it.
              public function calculateCustomPreferredSizeFromData():Number
                    var dropDownWidth:Number    = this.calculatePreferredSizeFromData(this.dataProvider.length).width+14;
                    if(dropDownWidth > this.width)
                        return dropDownWidth;
                    else
                        return this.width;
          ]]>
       </mx:Script>
    </mx:ComboBox>

Maybe you are looking for

  • Time machine doesn't see external hard drive on network

    I have a pair of external hard drives connected to my iMac, which is connected to my 2WIRE modem/router via Ethernet. I'm using one of them as a Time Machine drive. For the past couple years, I've been backing up the laptops in the house to that Time

  • Flex Cube - Deposits and CASA documentation

    Flex Cube - Deposits and CASA documentation: someone could help me to find documentation and information about CA SA and Deposits Flex CUbe MOdule ? Thanks.

  • How to use odiRef.getJDBCConnection("WORKREP") to store data in ODI Vars

    [blog |http://bahchis.com/2011/03/03/odi-repositories/] Sergey Bahchissaraitsev Hi Everyone, I saw in this blog the new 11g functionality to get the JDBC Connection Object for the Work Repository. I really want to use this in an ODI variable. Specifi

  • Is the setup of my macbook causing the back of the lid to get hot?

    Hello, I am physically disabled and use my macbook on my floor. I have carpet. Ihave my macbook on a book and I felt the screen hinge (I think that is what its called) was hot. As well as the back of the lid. Should I get my Dad to make me some type

  • Max Sounds in Flash!

    I just wanted to know what the maximum amount of sounds that can be played simultaneously in Flash CS3 are? I know that back in MX there was a limit of 8 sounds, but I haven`t seen this limit anywhere in the documentation for Flash CS3 / AS3.  I supp