Multiple selection using JLists

(I put this question in the wrong forum, so there is a cross post but because it is in the wrong one)
I have a JList that needs to allow for multiple slection of items, when i run the program I can select multiple items, BUT it only recognises that I have selected one of the items, the first one.
Why is this and how can I store the selected Items in seperate strings so that I can use them.
Any One know?
Cheers

Cross-post: http://forum.java.sun.com/thread.jspa?threadID=607480
Again, please don't cross-post.
Why shouldn't you cross-post? Well, look what happened yesterday: You posted the same message in the Swing forum, the Collections forum, and the Java Programming forum. Several people noticed about the same time, and now the thread in the Java Programming forum has a reply that points to the thread in the Collections forum, and the thread in the Collections forum has two replies that came about the same time, one pointing to the Swing forum and one pointing to the Java Programming forum. And people started to give you advice on how to solve your problem in both the Collections forum and in the Swing forum. This mess makes it very difficult for people to follow what is going on, and people will also spend unnecessary time posting a reply in one forum, where exactly the same thing already has been said by some other poster in another forum.

Similar Messages

  • How to use JList's ensureIndexIsVisible and multiple selection using CTRL

    Hello everyone. I am stuck on how to use JList's ensureIndexIsVisible() method and to also allow multiple rows in the list to be selected. Currently, when I begin typing a number stored in the list (i.e. 10001) the focus will go to that row; however, when I press the CTRL key and begin typing another number (i.e. 30001) the focus never goes to the new row. I have a suspicion that I need to cancel out the CTRL key somehow when typing the numbers but also need to keep the knowledge that the CTRL key is pressed to allow for multiple selection. Thanks in advance for your help!
    Regards,
    Will

    Hello everyone. I am stuck on how to use JList's ensureIndexIsVisible() method and to also allow multiple rows in the list to be selected. Currently, when I begin typing a number stored in the list (i.e. 10001) the focus will go to that row; however, when I press the CTRL key and begin typing another number (i.e. 30001) the focus never goes to the new row. I have a suspicion that I need to cancel out the CTRL key somehow when typing the numbers but also need to keep the knowledge that the CTRL key is pressed to allow for multiple selection. Thanks in advance for your help!
    Regards,
    Will

  • Multiple selection in JList

    How can I set up a JList that always uses multiple selection. That is, it acts as though the CTRL key is held down when the user selects items.

    Here's an example of multi-selection in a listbox, but using the shift key
    import java.awt.*;
    import java.awt.event.*;
    import java.net.*;
    import java.applet.*;
    public class Multi extends Applet implements KeyListener
         List list = new List(5, true);
         public void init()
              createGUI();
              setSize(300,300);
              this.setVisible(true);
         public void createGUI()
              for (int j = 0; j < 20; j++)
                   list.addItem("TESTING MULTI-SELECTION IN A LIST");
              add (list);
              list.addKeyListener(this);
         public void keyReleased(KeyEvent e)
              int key = e.getKeyCode();
              if (key == KeyEvent.VK_SHIFT)
                   int itm[] = list.getSelectedIndexes();
                   for(int i = itm[0]; i < itm[1]; i++)
                        list.select(i);
         public void keyTyped(KeyEvent e){}
         public void keyPressed(KeyEvent e){}
    }

  • Managing multiple selections using listModel......

    Hey,
    Im a newbie to java can anyone give me a pointer or two as to how I would go about removing multiple selections from a JList using listModel??
    Any help would be great.
    -Ben

    Why not try using the removeSelectionInterval(int,int) method of the JList itself? It should be fairly obvious as to how to proceed with this (i.e. stepping through the list element at a time, deselecting as necessary).
    I'm watching this topic if you need further help!

  • An issue with multiple selection using Func mod COMPLEX_SELECTIONS_DIALOG

    Hi All,
    I am using COMPLEX_SELECTIONS_DIALOG function module to display mutliple selection pop up for materials.
    The problem that Iam facing is that if a material  is deleted in multiple selection pop up, it is not been returned in the returning table.Only the materials avalible in the pop-up are returned in the internal table.
    Is there any way by which the deleted values could be tracked.
    Pls find below the code
    *Display the value in Multpl Selection pop up.
    CALL FUNCTION 'COMPLEX_SELECTIONS_DIALOG'
    EXPORTING
       TITLE                   = 'Include/Exclude Materials'
       TEXT                    = 'Pls select the materials'
       SIGNED                  = 'X'
       LOWER_CASE              = ' '
       NO_INTERVAL_CHECK      = 'X'
       JUST_DISPLAY            = ' '
      JUST_INCL               = 'X'
      EXCLUDED_OPTIONS        =
      DESCRIPTION             =
      HELP_FIELD              =
       SEARCH_HELP              = 'MAT1'
      TAB_AND_FIELD           =
      TABLES
        RANGE                   = T_MAT_INCLU_EXCLU
    EXCEPTIONS
       NO_RANGE_TAB            = 1
       CANCELLED               = 2
       INTERNAL_ERROR          = 3
       INVALID_FIELDNAME       = 4
       OTHERS                  = 5.
    Any help in this regard is highly apprecited.
    Warm regards,
    Partha.

    Applogise for posting this thread under a wrong node - ERP HCM .
    Closing the thread from this node  .
    Regards
    Sarmistha
    Edited by: sarmistha das on Mar 9, 2012 9:52 AM

  • Multiple Selection with JList

    Hello!
    I have a Frame with a JList that needs to be able to do multiple slection. The JList ist filled with special names which are found when the user opens a certain file. (so a file-chooser is here too) When the User selects a name every paragraph containing that name should be posted in a textarea.
    However, when i run the program I can select multiple items, BUT it just recognises that the user selected one of the items, and I think it's the first one clicked.
    How can I change that? I have used getSelectedValues() but it just won't work...
    Can someone please help?
    Thanks

    So getSelectedValues() is only returning an array of size 1?
    Paul

  • MULTIPLE SELECTION of Jlist only with mouse

    I want select many items of Jlist but I need make only with the mouse.
    I cann�t use keyboard.
    I don�t know how do it, because I selected
    listSelectionModel.MULTIPLE_INTERVAL_SELECTION
    but I need do a click in the first item and press key shif + click in the last item.
    but I must do a program only with the mouse.
    how I can make it?
    thanks

    hi,
    heres a quick and dirty version:
    set an ListSelectionModel at your List that overwrites the DefaultListSelectionModel class like this:
    ListSelectionModel selectionModel = new DefaultListSelectionModel() {
    int anchor = -1;
    public void setSelectionInterval(int index1, int index2) {
    if( index1 == index2 ){
    if( anchor = -1 ) anchor = index1;
    super.setSelectionInterval(anchor, index2);
    }else {
    super.setSelectionInterval(index1, index2);
    public void setValueIsAdjusting(boolean b) {
    super.setValueIsAdjusting(b);
    if(!b) anchor = -1;
    as long as single list entries should be selected, while the mouse is dragged ( valueIsAdjusting ), the entry is added to a selection range instead.
    I didnt compile the code, so maybe there are some syntax struggles.
    if you want to do it the hard and stoney way you have to implement a new ui class, that accomplish your needs.
    regards,
    stefan

  • Trying to create table using Union All Clause with multiple Select stmts

    The purpose of the query is to get the Substring from the value for eg.
    if the value is *2 ASA* then it should come as ASA
    where as if the value is *1.5 TST* the it sholud come as TST like wise for others too.
    I am trying to execute the below written SQL stmt but getting error as:
    *"ORA-00998 must name this expression with the column alias 00998.00000 - Must name this expression with the column alias"*
    CREATE TABLE TEST_CARE AS
    SELECT row_id, old_care_lvl,SUBSTR(old_care_lvl,3), len FROM test_care_lvl
    WHERE LENGTH(old_care_lvl) =5
    UNION ALL
    SELECT row_id, old_care_lvl,SUBSTR(old_care_lvl,3), len FROM test_care_lvl
    WHERE LENGTH(old_care_lvl) =7
    UNION ALL
    SELECT row_id, old_care_lvl,SUBSTR(old_care_lvl,3), len FROM test_care_lvl
    WHERE LENGTH(old_care_lvl) =14
    UNION ALL
    SELECT row_id, old_care_lvl,SUBSTR(old_care_lvl,3),LEN FROM test_care_lvl
    WHERE LENGTH(old_care_lvl) =7 AND old_care_lvl ='Regular'
    I want to create the table using the above given multiple select using the Union ALL clause but when trying to create run the query getting error as "ORA-00998 must name this expression with the column alias 00998.00000 - Must name this expression with the column alias"
    Please guide me how to approach to resolve this problem.
    Thanks in advance.

    When you create a table using a SELECT statement the column names are derived from the SELECT list.
    Your problem is that one of your columns is an expression that does not work as a column name SUBSTR(old_care_lvl,3)What you need to do is alias this expression and the CREATE will pick up the alias as the column name, like this:
    CREATE TABLE TEST_CARE AS
    SELECT row_id, old_care_lvl,SUBSTR(old_care_lvl,3) column3, len FROM test_care_lvl
    WHERE LENGTH(old_care_lvl) =5
    UNION ALL
    SELECT row_id, old_care_lvl,SUBSTR(old_care_lvl,3), len FROM test_care_lvl
    WHERE LENGTH(old_care_lvl) =7
    UNION ALL
    SELECT row_id, old_care_lvl,SUBSTR(old_care_lvl,3), len FROM test_care_lvl
    WHERE LENGTH(old_care_lvl) =14
    UNION ALL
    SELECT row_id, old_care_lvl,SUBSTR(old_care_lvl,3),LEN FROM test_care_lvl
    WHERE LENGTH(old_care_lvl) =7 AND old_care_lvl ='Regular'
    );You may not like the name "column3" so use something appropriate.

  • Multiple selection on Outlook

    Hi
    Did anyone notice that the option of multiple selection using command and shift is not operative as i tried and it would not allow multiple selection.
    thank you.
    Jeorme

    baguhan,
    then replace with this code.
    DECLARE
    Num_Total_Records NUMBER;
    Num_Loop_I           NUMBER;
    BEGIN
    GO_BLOCK(<BLOCK_NAME>);
    FIRST_RECORD;
    LAST_RECORD;
    Num_Total_Records := TO_NUMBER(NAME_IN('SYSTEM.CURSOR_RECORD'));
    FIRST_RECORD;
    FOR Num_Loop_I IN 1..Num_Total_Records LOOP
    IF <CHECKBOX> = 1 THEN
    <................................................>
    END IF;
    NEXT_RECORD;
    END LOOP;
    <................................................>
    END;
    Regards,
    Manu.

  • Is it possible to diable multiple selections in JTable and JList?

    as the title states, is it possible to disable multiple selections? how to prevent user from using ctrl or shift keys to select multiple rows?

    Use the setSelectionMode(ListSelectionModel.SINGLE_SELECTION ) for your JList / JTable.

  • Multiple-selection JList

    here is my another problem:
    how to retrieve the data (tables, columns) from access database to the JList? i already success connected database to the jdbc-odbc bridge...after got the all column names (JList2) from selected table (JList1), i would like to select the certain column name by clicking the ( > , <, >>, << jbutton1, 2, 3, 4 ) to the another JList (JList3) because not all the column is useful to use to analyse. i think i need to use multiple selection JList but i don't know how to start because i am new to java.
    thx!

    Usually data from a database would be stored in a JTable as it already provide support for multiple rows and columns:
    http://java.sun.com/docs/books/tutorial/uiswing/components/table.html
    Also, with JDK1.3 there is some sample code of using a JTable with a database. I'm not sure if the code actually runs, but at least you can look at the source to see the steps involved:
    jdk1.3\demo\jfc\TableExample\src>

  • How to use multiple selection parameters in the data model

    Hi, after have looked all the previous threads about how to use multiple selection parameters , I still have a problem;
    I'm using Oracle BI Publisher 10.1.3.3.2 and I'm tried to define more than one multiple selection parameters inside the data template;
    Inside a simple SQL queries they work perfectly....but inside the data template I have errors.
    My data template is the following (it's very simple...I am just testing how the parameters work):
    <dataTemplate name="Test" defaultPackage="bip_departments_2_parameters">
    <parameters>
    <parameter name="p_dep_2_param" include_in_output="false" datatype="character"/>
    <parameter name="p_loc_1_param" include_in_output="false" datatype="character"/>
    </parameters>
    <dataTrigger name="beforeReport" source="bip_departments_2_parameters.beforeReportTrigger"/>
    <dataQuery>
    <sqlStatement name="Q2">
    <![CDATA[
    select deptno, dname,loc
    from dept
    &p_where_clause
    ]]>
    </sqlStatement>
    </dataQuery>
    <dataStructure>
    <group name="G_DEPT" source="Q2">
    <element name="deptno" value="deptno"/>
    <element name="dname" value="dname"/>
    <element name="loc" value="loc"/>
    </group>
    </dataStructure>
    </dataTemplate>
    The 2 parameters are based on these LOV:
    1) select distinct dname from dept (p_dep_2_param)
    2) select distinct loc from dept (p_loc_1_param)
    and both of them have checked the "Multiple selection" and "Can select all" boxes
    The package I created, in order to use the lexical refence is:
    CREATE OR REPLACE package SCOTT.bip_departments_2_parameters
    as
    p_dep_2_param varchar2(14);
    p_loc_1_param varchar2(20);
    p_where_clause varchar2(100);
    function beforereporttrigger
    return boolean;
    end bip_departments_2_parameters;
    CREATE OR REPLACE package body SCOTT.bip_departments_2_parameters
    as
    function beforereporttrigger
    return boolean
    is
    l_return boolean := true;
    begin
    if (p_dep_2_param is not null) --and (p_loc_1_param is not null)
    then
    p_where_clause := 'where (dname in (' || replace (p_dep_1_param, '''') || ') and loc in (' || replace (p_loc_1_param, '''') || '))';
    else
    p_where_clause := 'where 1=1';
    end if;
    return (l_return);
    end beforereporttrigger;
    end bip_departments_2_parameters;
    As you see, I tried to have only one p_where_clause (with more than one parameter inside)....but it doesn't work...
    Using only the first parameter (based on deptno (which is number), the p_where_clause is: p_where_clause := 'where (deptno in (' || replace (p_dep_2_param, '''') || '))';
    it works perfectly....
    Now I don't know if the problem is the datatype, but I noticed that with a single parameter (deptno is number), the lexical refence (inside the data template) works.....with a varchar parameter it doesn't work....
    So my questions are these:
    1) how can I define the p_where_clause (inside the package) with a single varchar parameter (for example, the department location name)
    2) how can I define the p_where_clause using more than one parameter (for example, the department location name and the department name) not number.
    Thanks in advance for any suggestion
    Alex

    Alex,
    the missing thing in your example is the fact, that if only one value is selected, the parameter has exact this value like BOSTON. If you choose more than one value, the parameter includes the *'*, so that it looks like *'BOSTON','NEW YORK'*. So you need to check in the package, if there's a *,* in the parameter or not. If yes there's more than one value, if not it's only one value or it's null.
    So change your package to (you need to expand your variables)
    create or replace package bip_departments_2_parameters
    as
    p_dep_2_param varchar2(1000);
    p_loc_1_param varchar2(1000);
    p_where_clause varchar2(1000);
    function beforereporttrigger
    return boolean;
    end bip_departments_2_parameters;
    create or replace package body bip_departments_2_parameters
    as
    function beforereporttrigger
    return boolean
    is
    l_return boolean := true;
    begin
    p_where_clause := ' ';
    if p_dep_2_param is not null then
    if instr(p_dep_2_param,',')>0 then
    p_where_clause := 'WHERE DNAME in ('||p_dep_2_param||')';
    else
    p_where_clause := 'WHERE DNAME = '''||p_dep_2_param||'''';
    end if;
    if p_loc_1_param is not null then
    if instr(p_loc_1_param,',')>0 then
    p_where_clause := p_where_clause || ' AND LOC IN ('||p_loc_1_param||')';
    else
    p_where_clause := p_where_clause || ' AND LOC = '''||p_loc_1_param||'''';
    end if;
    end if;
    else
    if p_loc_1_param is not null then
    if instr(p_loc_1_param,',')>0 then
    p_where_clause := p_where_clause || 'WHERE LOC in ('||p_loc_1_param||')';
    else
    p_where_clause := p_where_clause || 'WHERE LOC = '''||p_loc_1_param||'''';
    end if;
    end if;
    end if;
    return (l_return);
    end beforereporttrigger;
    end bip_departments_2_parameters;
    I've written a similar example at http://www.oracle.com/global/de/community/bip/tipps/Dynamische_Queries/index.html ... but it's in german.
    Regards
    Rainer

  • Use a multiple selection parameter in the data model

    Hi
    i have created a parameter with the property multiple selection.
    This parameter i use in the Data Model where area,
    if i just mark one value the report works well if i mark more the one
    the report run into a error.
    WHERE PSNR IN :ma
    the xdo looks like
    <?xml version = '1.0' encoding = 'utf-8'?>
    <report version="1.1" xmlns="http://xmlns.oracle.com/oxp/xmlp" defaultDataSourceRef="tisoware">
    <title>BDE Nettozeit</title>
    <properties>
    <property name="showControls" value="true"/>
    <property name="online" value="true"/>
    <property name="parameterColumns" value="2"/>
    <property name="openLinkInNewWindow" value="true"/>
    </properties>
    <dataModel defaultDataSet="BDERUECK">
    <dataSet id="BDERUECK">
    <sql dataSourceRef="tisoware">
    <![CDATA[SELECT (SUBSTR(DATUM,1,6)) AS DATUM, SUM(NTTOZEIT) AS ZEIT,
    TRUNC(SUM(NTTOZEIT)/60) AS STUNDE
    FROM BDERUECK
    WHERE (DATUM  >= :datev) AND (DATUM <= :dateb) AND (KZDELETE = 'N') AND FIRMA = '1' AND ((PSNR IN :ma))
    GROUP BY (SUBSTR(DATUM,1,6))]]>
    </sql>
    <input id="datev" value="${datev}" dataType="xsd:string"/>
    <input id="dateb" value="${dateb}" dataType="xsd:string"/>
    <input id="ma" value="${ma}" dataType="xsd:string"/>
    </dataSet>
    </dataModel>
    <valueSets>
    <valueSet id="date">
    <sql dataSourceRef="tisoware">
    <![CDATA[SELECT DISTINCT DATUM
    FROM BDERUECK]]>
    </sql>
    </valueSet>
    <valueSet id="employee">
    <sql dataSourceRef="tisoware">
    <![CDATA[select      PERSTAMM.PSPERSNR as PSPERSNR,
          PERSTAMM.PSNR as PSNR
    from      TISOWARE.PERSTAMM PERSTAMM
    where    PERSTAMM.FIRMA = '1'
    order by PERSTAMM.PSPERSNR]]>
    </sql>
    </valueSet>
    </valueSets>
    <parameters>
    <parameter id="datev" defaultValue="20050103">
    <select label="Datum von : " valueSet="date" multiple="false" all="false" refreshParameters="false"/>
    </parameter>
    <parameter id="dateb" defaultValue="20060930">
    <select label="Datum bis : " valueSet="date" multiple="false" all="false"/>
    </parameter>
    <parameter id="ma" defaultValue="152">
    <select label="Mitarbeiter : " valueSet="employee" multiple="true" all="false"/>
    </parameter>
    </parameters>
    <templates default="BDE Nettozeit">
    <template label="BDE Nettozeit" type="rtf" url="BDE Nettozeit.rtf"/>
    </templates>
    </report>

    Alex,
    the missing thing in your example is the fact, that if only one value is selected, the parameter has exact this value like BOSTON. If you choose more than one value, the parameter includes the *'*, so that it looks like *'BOSTON','NEW YORK'*. So you need to check in the package, if there's a *,* in the parameter or not. If yes there's more than one value, if not it's only one value or it's null.
    So change your package to (you need to expand your variables)
    create or replace package bip_departments_2_parameters
    as
    p_dep_2_param varchar2(1000);
    p_loc_1_param varchar2(1000);
    p_where_clause varchar2(1000);
    function beforereporttrigger
    return boolean;
    end bip_departments_2_parameters;
    create or replace package body bip_departments_2_parameters
    as
    function beforereporttrigger
    return boolean
    is
    l_return boolean := true;
    begin
    p_where_clause := ' ';
    if p_dep_2_param is not null then
    if instr(p_dep_2_param,',')>0 then
    p_where_clause := 'WHERE DNAME in ('||p_dep_2_param||')';
    else
    p_where_clause := 'WHERE DNAME = '''||p_dep_2_param||'''';
    end if;
    if p_loc_1_param is not null then
    if instr(p_loc_1_param,',')>0 then
    p_where_clause := p_where_clause || ' AND LOC IN ('||p_loc_1_param||')';
    else
    p_where_clause := p_where_clause || ' AND LOC = '''||p_loc_1_param||'''';
    end if;
    end if;
    else
    if p_loc_1_param is not null then
    if instr(p_loc_1_param,',')>0 then
    p_where_clause := p_where_clause || 'WHERE LOC in ('||p_loc_1_param||')';
    else
    p_where_clause := p_where_clause || 'WHERE LOC = '''||p_loc_1_param||'''';
    end if;
    end if;
    end if;
    return (l_return);
    end beforereporttrigger;
    end bip_departments_2_parameters;
    I've written a similar example at http://www.oracle.com/global/de/community/bip/tipps/Dynamische_Queries/index.html ... but it's in german.
    Regards
    Rainer

  • Multiple people using multiple select list

    Hi,
    First of all, let me congratulate Oracle HTML DB for bringing such a great product. It is extremely powerful, and useful.
    I have multiple people using a form which has multiple selects in it and calls an Oracle report. I looked at couple of examples and I couldn’t understand how IDs work in this scenario. It is not clear if I need to create an id on HTML DB side or on the Oracle reports side or at the database level. Obviously, if people delete or select each others selected parameters, it is a big issue. Could you please explain me about how this is achieved.

    The touch ID is only for accessing the device, no log is kept, and no apps can access its details.
    You can create multiple fingerprints within a single device so more than 1 person could access it, but there is no detail of who accessed it or when.
    You may be better served looking at a portable time clock device that uses RFID cards for login and out or similar to this
    http://www.mjobtime.com/default.aspx?source=adwords&kw=portable+time+clock&gclid =CLWz2Pat18ACFSsV7AodCTsALQ

  • OBIEE - Using Multiple Select Rows In Grid As Parameters

    Hello All,
    First post from an OBI Newbie. I am getting used to creating dashboards and have got my head around drilling with values, but I have a user requirement that I am not sure is possible.
    A standard query returns the following datagrid information ("," = column divider):
    Product Id, Product Description, Colour, Total Sales
    1, Chair, Red, 4
    2, Chair, Blue, 3
    3, Chair, Black, 5
    I know that I can enable a drill on a specific colour to give a datagrid such as (if Red Selected):
    Order Reference, Product Id, Product Description, Colour, Units
    687678657, 1, Chair, Red, 3
    687678658, 1, Chair, Red, 1
    The user requirement is to select multiple rows (possible by holding Ctrl) and to then effectively "drill" with the multiple selected values. Eg Red, Blue:
    Order Reference, Product Id, Product Description, Colour, Units
    687678657, 1, Chair, Red, 3
    687678658, 1, Chair, Red, 1
    687678660, 2, Chair, Blue, 3
    I presume that a separate report will be required, but I am not sure how to trigger and/or pass the multiple product id's. Can anyone help with a solution?
    Edited by: 885689 on 16-Sep-2011 06:27

    I got this working by changing the signature of the Application Module method to use ArrayList rather than String[], then you can marshal the Struts FormBean contents into an ArrayList to pass up.
    To do this, subclass the DataAction by using "Go To Code" off of the context menu and then override the initializeMethodParameters() method:
      protected void initializeMethodParameters(DataActionContext actionContext, JUCtrlActionBinding actionBinding)
        //Get the String Array from the Form Bean
        String[] selection = (String[])((DynaActionForm)actionContext.getActionForm()).get("multiSelect");
        //convert that to an ArrayList
        ArrayList selectionArr = new ArrayList( Arrays.asList(selection));
        //Add that object to the Arg List for the AM method
        ArrayList params = new ArrayList();
        params.add(selectionArr);
        actionBinding.setParams(params);
      }

Maybe you are looking for