Dealing with multiple combo boxes.

Hi all,
Yesterday I started a thread on the topic of using a main JComboBox, that when you select one of its items, 2 sub combo boxe's models are changed. Michael_Dunn helped me on this and gave me a great example. However, I don't want to have the 2nd combo box change the contents of the 3rd. I'd like the 1st combo box to control both the 2nd and the third. I modified his code a bit to make this true. However, when you select an item on the 1st box, and then change the item on either the 2nd or 3rd box, it sets the selection to both the 2nd and 3rd box. I'd like these boxes to behave normally, without one changing the other, except for the 1st boxe's control. This sounds a bit confusing the way I explain it, so just check out the code and you'll see what I mean. Also, here's the link to my previous thread: http://forum.java.sun.com/thread.jspa?threadID=702577 Any help would be greatly appreciated! Thanks!
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
class Testing extends JFrame
  String[] cbo1Text = {"Snacks","Drinks","Cigarettes"};
  String[][] cbo2Text = {{"Chocolate Bar","Chips","Candy"},{"Soft","Beer","Wine","Spirits"},
                       {"Menthol","Camel","Marlboro","Lite"}};
  String[][][] cbo3Text = {{{"Choc1","Choc2","Choc3"},{"Chips1","Chips2","Chips3"},{"Candy1","Candy2","Candy3"}},
                      {{"Coca Cola","Pepsi","Dr Pepper","Solo"},{"Bud","Coors","Heinekken"},
                       {"Champagne","Chardonnay","Shiraz"},{"Bourbon","Scotch","Vodka"}},
                      {{"Menthol15","Menthol20","Menthol40"},{"Camel15","Camel20","Camel40"},
                       {"Marlboro15","Marlboro20","Marlboro40"},{"Lite15","Lite20","Lite40"}}};
  JComboBox cbo1 = new JComboBox(cbo1Text);
  JComboBox cbo2 = new JComboBox(cbo2Text[0]);
  JComboBox cbo3 = new JComboBox(cbo3Text[0][0]);
  public Testing()
    super("JComboBox Test");
    setDefaultCloseOperation(EXIT_ON_CLOSE);
    setLocation(400,300);
    setSize(300,300);
    getContentPane().setLayout(new FlowLayout());
    cbo1.addActionListener(new ActionListener(){
      public void actionPerformed(ActionEvent ae){
        DefaultComboBoxModel cbo2NewModel = new DefaultComboBoxModel(cbo2Text[cbo1.getSelectedIndex()]);
        cbo2.setModel(cbo2NewModel);
        DefaultComboBoxModel cbo3NewModel = new DefaultComboBoxModel(cbo3Text[cbo1.getSelectedIndex()]/*[0]*/);
        cbo3.setModel(cbo3NewModel);}});
    /*cbo2.addActionListener(new ActionListener(){
      public void actionPerformed(ActionEvent ae){
        DefaultComboBoxModel cbo3NewModel = new DefaultComboBoxModel(cbo3Text[cbo1.getSelectedIndex()][cbo2.getSelectedIndex()]);
        cbo3.setModel(cbo3NewModel);}});*/
    getContentPane().add(cbo1);
    getContentPane().add(cbo2);
    getContentPane().add(cbo3);
  public static void main(String[] args){new Testing().setVisible(true);}
}

this line
cbo3.setModel(cbo3NewModel);}});
which you changed to
cbo3.setModel(cbo2NewModel);}});
should be
cbo3.setModel(new DefaultComboBoxModel(cbo2Text[cbo1.getSelectedIndex()]));}});

Similar Messages

  • Help with linking combo boxes so that some options are made unavailable

    Hello!
    I'm having trouble setting up an interactive PDF form with multiple combo boxes.
    I have designed an interactive PDF form in InDesign CS6 but am doing the final preparation and formatting in Adobe Acrobat XI Pro.
    First of all, I am not sure if I should be using combo boxes or list boxes, but the combo box seemd to look better after I export the PDF and also left the field blank, ready for selection from the drop-down menu.
    Basically I have a list of drop-down lists, but not all combinations are compatible. For example, after maing "Selection 1" in "Combo box 1", I need only "Selection 1", "2", and "3" [out of the total 5] to be available in "Combo box 2".
    I need to be able to apply this algorhythm to the next few combo boxes as well.
    Moreover, I would need some of the checkboxes disabled [the user won't be able to check them at all]when I make a certain selection in some of the combo boxes.
    Needless to say, I don't know any Java, coding or making calculations in LiveCycle Designer, so I don't even know where to begin.
    I have attached a screen grab of my form and what I want to achieve.
    Any help would be very much appreciated.
    Thank you!

    If it is static data, I would suggest you to cache it rather than having it in each of the user session. You can have configuration/code to refresh when needed. Please look at any available caching frameworks (EhCache, OSCache etc...)

  • Howto deal with multiple source files having the same filename...?

    Ahoi again.
    I'm currently trying to make a package for the recent version of subversive for Eclipse Ganymede and I'm almost finished.
    Some time ago the svn.connector components have been split from the official subversive distribution and have to be packed/packaged extra. And here is where my problem arises.
    The svn.connector consists (among other things) of two files which are named the same:
    http://www.polarion.org/projects/subversive/download/eclipse/2.0/update-site/features/org.polarion.eclipse.team.svn.connector_2.0.3.I20080814-1500.jar
    http://www.polarion.org/projects/subversive/download/eclipse/2.0/update-site/plugins/org.polarion.eclipse.team.svn.connector_2.0.3.I20080814-1500.jar
    At the moment makepkg downloads the first one, looks at its cache, and thinks that it already has the second file, too, because it has the same name. As a result, I can neither fetch both files nor use both of them in the build()-function...
    Are there currently any mechanisms in makepkg to deal with multiple source files having the same name?
    The only solution I see at the moment would be to only include the first file in the source array, install it in the build()-function and then manually download the second one via wget and install it after that (AKA Quick & Dirty).
    But of course I would prefer a nicer solution to this problem if possible. ^^
    TIA!
    G_Syme

    Allan wrote:I think you should file a bug report asking for a way to deal with this (but I'm not sure how to fix this at the moment...)
    OK, I've filed a bug report and have also included a suggestion how to solve this problem.

  • Plotting a combination chart with a combo box for selection

    Hi:
    I am a newbie using xcelcius and I need help on the following:-
    I need to create a combination chart that plots 3 years data by month, and I need a combo box selection at the top that allows me to select user display for each difference region. I manage to create one that plots only 2008 data with a combo-box selection, but I have no idea how to do it for a combi chart in xcelcius. Any advise?

    Hi Ning,
    I assume your data are like this:
    Region             Year     Jan     Feb     Mar
    APJ             2006     $234.45     $310.34     $321.54
    APJ             2007     $314.35     $319.12     $256.89
    APJ             2008     $425.54     $354.34     $285.73
    North Asia     2006     $534.64     $642.35     $484.64
    North Asia     2007     $631.74     $654.13     $754.34
    North Asia     2008     $754.31     $423.65     $634.32
    South East Asia     2006     $536.42     $576.35     $525.42
    South East Asia     2007     $426.78     $876.43     $643.75
    South East Asia     2008     $634.87     $425.77     $732.43
    If this, you can set the insertion type of combo box is "Filtered Rows", see steps:
    1) For Combo Box, bind General > Labels to the Region column.
    2) Set General > Data Insertion > Insertion Type is "Filtered Rows" (you can refer to following flash to see how "Filtered Rows" works).
    3) Set its Source Data are Year, Jan, Feb, ... columns and Destination to blank cells.
    4) Bind Chart to the destination data.
    Now when you select APJ from Combo Box, it will insert all the rows of APJ data to the desitination cells which will be displayed in Chart.
    Hope this can help!

  • How do i deal with multiple iPhoto libraries when migrating to Photos

    how do i deal with multiple iPhoto libraries when migrating to Photos

    I would merge them before the migration.  Also, spend some time doing any batch changes of names and dates beforehand too.
    iPhoto Library Manager has good merge and duplicate search facilities.
    http://www.fatcatsoftware.com/iplm/

  • A data-binding issue with a combo box.

    Hi,
    Iu2019m having a data-binding issue with a combo box.  The field it is bound to is an integer.  The valid values in the combo box are 1, 2, and 3.  If I add a record when it is set to 1 or 2, the value gets stored correctly.  If I add a record when it is set to 3, it is stored as 1.  However, I can bring up the record just added on the form, change it to 3, and click u201CUpdateu201D and it is saved correctly as 3.  If I change it so that the valid values are 4, 5, and 6, it saves a 1 regardless of what is selected in the combo box.  It looks like the combo box is correctly bound for updates but not for adds.  The table is a master type UDO.  Any ideas?  Iu2019m somewhat committed to the field being an integer.  I'm using 2007A PL47.
    Thanks,
    Mike
    Edited by: Mike Angelastro on Jul 1, 2009 2:43 PM

    I tried a few things on my own.  The result is that I decided that it was not a good idea to use a combo box bound to an integer (numeric) field.  I donu2019t think the SDK can handle it.  The reason it was an integer field in the first place is that before I changed it to a combo box it was a group of two option buttons.  Option buttons use an integer (numeric) field.  This worked just fine until I added a third option; the SDK didnu2019t handle the third option correctly when adding records.  I thought that using a combo box instead would fix that.  I was wrong; the problem remained.  So I decided to use a character (alphanumeric) field instead.  This works just fine.
    So here is my advice:  Never use option buttons if they need to be bound to the database; a combo box will actually work better when bound to the database.  But use a character (alphanumeric) field.
    Edited by: Mike Angelastro on Jul 5, 2009 9:15 PM

  • How to deal with multiple disk path's

    hi
    i'm setting up a new server with virtual servers with extra io domain's
    now i have a question on how to deal with multiple disk path's
    so following questions:
    - can i enable multipath on the primary and on the alternate domain?
    i tried this but when rebooting the alternate the alternate keep's freezing and the only solution is to hard stop it and it's depending host
    - if i can't enable multipathing how to handle this
    for example a disk has on the primary domain 4 path's to a disk
    do  i then assign all 4 path's to a virtual disk server or do i create a virtual disk server per path
    if i do the first is adding all the path to the same mpgroup enough or not

    Hello
    1.-can i enable multipath on the primary and on the alternate domain?  Yes. i understand for multipath mpxio or similar.
    2.-i tried this but when rebooting the alternate the alternate keep's freezing and the only solution is to hard stop it and it's depending host
    if you are going to use alternate domain you have to give this IO the all bus root nexus, what you describe sounds like DIO,
    3.- - if i can't enable multipathing how to handle this for example a disk has on the primary domain 4 path's to a disk
    If you have 4 path to the same disk in the primary and you are using multipath let's say mpxio, then you will have only one disk in the primary, which is a virtual device that handle the 4 paths.  That's is what you have to use in a vds.
    Please check this doc to see the best practice to ldom
    white-paper-ldom
    regards
    eze

  • Linking multiple combo boxes

    Hello,
    I need some help with something that I am having trouble wrapping my head around. I am in the midst of creating some forms for our office that were originally MS Word files that have since been converted to PDF's. On these forms (which are now compiled into one PDF) there is a field for a name and one fore a licence number. What I would like to do (if possible) is have a drop down combo box with the pilots name. Once the name has been selected, it automatically populates the pilots name and licence number on the subsequent forms.
    Is this possible and if so, does someone have a tutorial on how to do this? I have not had much luck looking online but thought perhaps someone on here may have tired something similar before.
    Thanks.
    Chris

    Yes it's possible. For some help, check out: http://www.acrobatusers.com/tutorials/2007/js_list_combo_livecycle/
    There is a part 2 to this article that may help as well.
    George

  • Problems with a combo box in dynpro

    Hi guys, im creating a combo box in a dynpro, but is not showing anything.
    the code is the following:
    AT the screen painter..
    MODULE USER_COMMAND_0100.
       PROCESS ON VALUE-REQUEST.
      FIELD TI_COMBO MODULE create_dropdown_box.
    *then the module in the main program.....
    module create_dropdown_box input.
    TYPES: BEGIN OF type_carrid,
             op1(20),
             ID TYPE N,
           END OF type_carrid.
    DATA ti_combo TYPE STANDARD TABLE OF type_carrid WITH HEADER LINE.
    ti_combo-op1 = 'Not processed'.
    TI_COMBO-ID = 1.
    append ti_combo.
    ti_combo-op1 = 'Duplicated.
    append ti_combo.
    ti_combo-op1 = 'For Payroll'.
    append ti_combo.
      CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
           EXPORTING
            RETFIELD = 'ID'
            DYNPPROG = SY-REPID
            DYNPNR = '100'
            DYNPROFIELD = 'TI_COMBO'
            VALUE_ORG = 'S'
           TABLES
                value_tab       = ti_combo
           EXCEPTIONS
                parameter_error = 1
                no_values_found = 2
                OTHERS          = 3.
      IF sy-subrc <> 0.
      ENDIF.
    endmodule.
    Edited by: javier  santana on May 7, 2008 5:47 PM

    Hi,
    Check the below code.
    TYPE-POOLS: VRM.
    DATA:V_NUM TYPE I.
    DATA:NAME TYPE VRM_ID,
         LIST TYPE VRM_VALUES,
         VALUE LIKE LINE OF LIST.
    DATA:I_WORKPATTERN LIKE ZWORKPAT OCCURS 0 WITH HEADER LINE.
    DATA:ZPATTXT(60).
    MODULE WORKPATTERN_LISTBOX OUTPUT.
    NAME = 'P9434-ZWORKPATTERN'.
        IF V_NUM IS INITIAL.
        CLEAR I_WORKPATTERN.
        REFRESH I_WORKPATTERN.
        SELECT *
               FROM ZWORKPAT
               INTO TABLE I_WORKPATTERN.
        IF NOT I_WORKPATTERN[] IS INITIAL.
          LOOP AT I_WORKPATTERN.
            VALUE-KEY = I_WORKPATTERN-ZWORKPATTERN.
            VALUE-TEXT = I_WORKPATTERN-ZWORKPATTERN.
            APPEND VALUE TO LIST.
          ENDLOOP.
        ENDIF.
        CALL FUNCTION 'VRM_SET_VALUES'
          EXPORTING
            ID                    = NAME
            VALUES                = LIST
         EXCEPTIONS
           ID_ILLEGAL_NAME       = 1
           OTHERS                = 2.
        IF SY-SUBRC <> 0.
          CLEAR SY-SUBRC.
        ENDIF.
        V_NUM = V_NUM + 1.
        ENDIF.

  • How to deal with multiple language SQL script?

    Hi All,
    We now want to create a SQL script that contains multiple languages(English, Chinese, Japanese), this script need to be run at there different database installed on different OS, for example, Oracle9i on Windows 2000 English Edition/Chinese Edition/Japanese Edition.
    If I save the file as ANSI format, this file will only be recognized at local OS(e.g. the Chinese and Japanese character will not be normally displayed on other OS, if I run the script, the CH/JP characters will not be stored normally in DB).
    If I save the file as Unicode format, this file can be recognized by all three OS, but Oracle SQL Plus will not recognize it, thus we can't run the script.
    Who can tell me how to deal with this issue? Is it possible to save only one script that can run on different language OS?
    Thanks,
    Spark

    Hi,
    The ISQLplus supports multiple languages, but there will be following problems for my case:
    1.ISQLplus don't support Unicode format script too, so I must save the file as ANSI format.
    2.To display the characters normally depends on the database server's platform. I create a script contain three languages with ANSI format in Chinese OS, but if I want to load this script to database server installed on English OS via ISQLplus, the Chinese characters will not be displayed normally too.
    PS:
    So, I think this is not only related with Oracle but also the Windows OS, it is hard to create one file with ANSI format that can be displayed normally in different platforms.
    Thank you all the same,
    Spark

  • Multiple combo boxes

    Hi all,
    New to this forum. Hoping someone might be able to help or
    point me in the right direction. I`m trying to use three combo
    boxes, with each combination of choices taking the user to a
    different frame. Is this possible? Any hints of where to start?
    Many thanks in advance!

    Thanks for your reply. I have now got as far as being able to
    tell which item has been selected from two combo boxes, but can`t
    seem to use them outside of this function. I tried declaring as
    global variables but still can`t get it to work.
    Heres my code:
    var myComboBox1:mx.controls.ComboBox;
    myComboBox1.removeAll();
    myComboBox1.addItem("--Choose--", "Choose");
    myComboBox1.addItem("one", "1");
    myComboBox1.addItem("ten", "10");
    myComboBox1.addItem("twenty", "20")
    myComboBox2.removeAll();
    myComboBox2.addItem("--Choose--", "Choose");
    myComboBox2.addItem("a", "a1");
    myComboBox2.addItem("b", "b10");
    myComboBox2.addItem("c", "c20")
    //Check taking the correct value from combo box 1
    myComboBox1.addEventListener("change", doChange1);
    function doChange1 (evt1){
    trace ("Combo box 1 " + evt1.target.value);
    _global.varResult_1=evt1.target.value
    //Check taking the correct value from combo box 2
    myComboBox2.addEventListener("change", doChange2);
    function doChange2 (evt2){
    trace ("Combo box 2 " + evt2.target.value);
    varResult_2=evt2.target.value
    //Try to choose which frame to go to depending on both combo
    boxes
    function checkResult(){
    //varResult_1=myComboBox1.value
    //varResult_2=myComboBox2.value
    if((_global.varResult_1==10)&(_global.varResult_2==b10)){
    gotoAndStop(10)
    function doChange(evt1) {
    trace("Value changed to 1" + _global.varResult_1);
    trace("Value changed to 2" + evt2.target.value);
    checkResult()
    Can anyone give me any hints of where I am going wrong or
    where to look for help?
    Thanks again

  • Multiple combo boxes cause application freeze

    I have an application that uses 3 combo boxes, they appear if
    the remoting service populates them.
    The actionscript is very simple, I only add items, removeall,
    and sort them by their label.
    If I use old MX combo box, my application works perfectly.
    If I use the Version 2 components, the application works when
    I select one of the combo boxes, but the second I touch the second
    combo box, it locks up the application and I get the message that a
    script is running, should I abort...
    I am using Flash 8 and want to stick with all V2 components,
    but...
    anybody experience this issue? I have a lot of other V2
    components on the application, all work, except this combobox
    issue.
    thanks
    Josh

    You can create a JavaScript array of the items and values to be set into the combo boxes and then use Acrobat's JavaScript's ''setItems()' method to load the fields.
    Get various fields (combo or list) and set items in the list using various techniques. 
    var l = this.getField("ListBox");
    l.setItems(["One", "Two", "Three"]);
    var c = this.getField("StateBox");
    c.setItems([["California", "CA"],["Massachusetts", "MA"],
    ["Arizona", "AZ"]]);
    var c = this.getField("NumberBox");
    c.setItems(["1", 2, 3, ["PI", Math.PI]]);

  • Problem with editable combo box and creating dynamic table values using js

    Hai
    I have used jquery.jec.js to make my dropdown list as editable... I need to create dynamic table values on the onChange event of dropdown using javascript.
    Now am facing the problem in it...
    I am getting duplicate rows in the table... think(assumption) this jquery.jec.js is calling the dropdown again creating duplicate values...
    Please help me out.... Any help is appreciable... Thanks in advance

    Thanks elOpalo, for your valuable response....
    I have found the correct way of doing.
    Before i had my code like this,
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <title>test</title>
    <script type="text/javascript" src="js/jquery-latest.js"></script>
    <script type="text/javascript" src="js/jquery.jec.js"></script>
    <script type="text/javascript">
    $(function(){
    $('#list').jec();
    function giveAlert(){
         alert('hello');
    </script>
    </head>
    <body>
    <form>
    Combo Box:
    <select id="list" name="list" onChange="giveAlert();">
    <option value="1">one</option>
    <option value="2">two</option>
    </select>
    </form>
    </body>
    </html>
    Now i have changed as the following,
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <title>test</title>
    <script type="text/javascript" src="js/jquery-latest.js"></script>
    <script type="text/javascript" src="js/jquery.jec.js"></script>
    <script type="text/javascript">
    $(function(){
    $('select.combo').jec();
    $('select.combo')
    .change(function() {
    alert($(this).val());
    }).change();
    </script>
    </head>
    <body>
    <form>
    <table>
    <tr>
    <td>Combo Box:</td>
    <td><select class="combo"><option value="b">banana</option><option value="a">apple</option></select></td>
    </tr>
    </table>
    </form>
    </body>
    </html>
    The problem is with the function i have called on the onChange Event.. Now i have defined it inside the jquery function of dropdown to make it as editable...

  • Can I use an LOV with a Combo Box?

    ... and if so, how?
    This should be easy, but I've been searching for over an hour now and I keep getting instruction on how to do each individually, but not how to put them together for the desired behavior.
    My goal is to have a combo box (single line text field with a drop down arrow) that, when the user clicks the arrow, displays a list populated from a column in the data base and the user selects a value.
    I'm using Oracle 10g2
    Thanks in advance,
    Darren

    Why don't you create a record group and populate that record group into the list item on runtime?
    -Ammad

  • How to deal with multiple hard drives?

    I am using Aperture 1.5 but am having trouble
    dealing with the Library structure. I want to be able to have Aperture recognize and work with Projects located on several different external hard drives. Where should the main library be located? In 1.5 is there such a thing anymore as a Branch library? I had a branch library on an external drive. I may have messed things up so that Aperture doesn't quite know where things are. Is there a way to re-organize things so that when I open Aperture ALL the projects I've worked with do appear? Thanks.

    To have Aperture work with projects on different hard drives, just import the project files but tell Aperture to copy the files from their current location (say a media card or CD) to a directory of your choice on any drive of your choice. You can store projects on multiple drives. I don't think it matters where the main library is located, it could be on your primary drive, or on one of your external hard drives. I'm not sure how to consolidate projects that were enclosed in different libraries other than to export the projects individually, and then reimport them into the new centralized library. I do wish Aperture would allow one multiple select projects (it only allows you to select one at a time) for exporting. I also wish that Aperture had a 'Consolidate Libraries' command which would allow one to just pull all 'found' projects into one library.
    Dual 2.7 GHz 5.5 Gig RAM   Mac OS X (10.4.6)  

Maybe you are looking for