JList Selection Event

Hi, here is one problem i am facing.
i have a JList and i am using Selection Listener for that. Now selection listener has only one even in it valueChanged. which is only fired when some value is changed in the JList, i.e., if we select the same value twice consecutively, this event is fired only once only when that value is selscted for the first time. but i want this even to be fired every time i select a value (even twice or thrice consecutively). can u plz help me or tell me any other event?
-Ashish

problem is I cannot recieve which chat room is selected (let's say I don't know how to get it :) )Sorry I didn't get the humor :-( So let's try a dry answer:
Try "jlist.getSelectedValue()" and cast it to the common supertype of all objects stuffed in the JList's model (I assume they are String or ChatRoom objects).
and also selected index is appended twice when I click on any of them ? Can it be done by double click ?You receive two events (deselection of current item - selection of new item). You can distinguish them with event.getValueIsAdjusting().
Brgds.

Similar Messages

  • JList selection is listened twice

    Hi
    How to make JList selection listener to catch selection events for only one mouse click (mouse pressed or mouse released)

    Hi,
    you are right!
    first time e.getValueIsAdjusting() is true second time
    it is false. It does not corrspond to mousePressed or mouseReleased. I think the first is an item loosing selection and the second is another item getting selection (just a guess).
    Phil

  • Select or deselect multiple rows with one single selection  event

    Does anyone know how to create a JTable which can select or deselect multiple rows with one single selection event in JTable. Fore example, if the table has
    row1
    row2
    row3
    row4
    row5
    row6
    What I need is when user select row1 or row2, both row1 and row2 should be set to be selected. Then if user press CTRL and click one of row3 or row4, both of them should be selected including the previouse selected row1 and row2.
    For deselection, if row1 and row2 are selected, when users deselect one of row1 or row2, both of them should be deselected.
    Hopefully someone can give me a hint.

    Here is a partial solution using a JList. Only one line gets highlighted when the user makes a selection in the list. But, two lines are returned. There is a blank line between every two lines.
         private void addLineToList() {
              String a = f_one.getText();
              String b = f_two.getText();
              if (a.length() == 0) {
                   Utils.showInformationMessage("Item field is empty.");
                   f_one.requestFocusInWindow();
                   return;
              if (b.length() == 0) {
                   Utils.showInformationMessage("Match field is empty.");
                   f_two.requestFocusInWindow();
                   return;
              model.addElement("item: " + a);
              model.addElement("match: " + b);
              model.addElement(" ");
              int size = model.getSize();
              pairList.setSelectedIndex(size - 3);
              f_one.setText("");
              f_two.setText("");
              f_one.requestFocusInWindow();
         private void editList() {
              if (pairList.getSelectedValue().toString().equalsIgnoreCase(" ")) {
                   Toolkit.getDefaultToolkit().beep();
                   f_one.requestFocusInWindow();
                   return;
              if (!f_one.getText().equals("")) {
                   int result = JOptionPane.showConfirmDialog(this,
                   "The Item field contains text. Replace the text?",
                   "Flash Card Activity", JOptionPane.YES_NO_OPTION,
                   OptionPane.INFORMATION_MESSAGE);
                   if (result == JOptionPane.NO_OPTION) return;
              if (!f_two.getText().equals("")) {
                   int result = JOptionPane.showConfirmDialog(this,
                   "The Match field contains text. Replace the text?",
                   "Flash Card Activity", JOptionPane.YES_NO_OPTION,
                   JOptionPane.INFORMATION_MESSAGE);
                   if (result == JOptionPane.NO_OPTION) return;
              String item = "";
              String match = "";
              int index = pairList.getSelectedIndex();
              String choice = model.getElementAt(index).toString();
              if (choice.startsWith("item")) {
                   item = choice;
                   match = model.getElementAt(index + 1).toString();
                   model.remove(index);
                   model.remove(index);
                   model.remove(index);
              else {
                   item = model.getElementAt(index - 1).toString();
                   match = choice;
                   model.remove(index + 1);
                   model.remove(index);
                   model.remove(index - 1);
              int size = model.getSize();
              if (size > 2) {
                   pairList.setSelectedIndex(size - 2);
              f_one.setText(item.substring(6));
              f_two.setText(match.substring(7));
              f_one.requestFocusInWindow();
         }

  • How to 'veto' a jList selection change

    Hi All,
    I have a JList which I'm using as a record selector - so whenever my user selects an item on the list, the associated record is loaded up into the other controls on this form for editing. If the user edits any of the data items, I want to ask whether to save changes or not if another item is selected from the JList. So, I've added code in my 'selection changed' function to check for changes and show a 'yes/no/cancel' JOptionPane. The code for my 'yes' and 'no' respones work fine - either save the changes or not, then show the next record. My problem is handling if a user clicks cancel...
    If the user selects 'Cancel', I dont want any of my "show new record" code to execute (this is easy, I can just 'return' out of the function) but also I don't want the JList selection to change. I've tried calling setSelectedIndex() back to the originally selected item, but this in turn triggers my 'selection changed' function to be called again, which causes the user to be asked twice whether they want to save changes!
    So, what I'm after is a kind of beforeSelectionChanged event, which allows the possibility of denying the selection change - but it doesn't look like this exists! I vaguely remember another language (possibly C++/MFC) having this - the user's action could be ignored depending on the return value of the function. Can anyone offer a way of achieving this in Java?
    (It's been a while since I last touched Java, and I'm a complete n00b with Swing. Using NetBeans as my IDE.)
    Thanks in advance for any suggestions!
    Andy

    The way I do it, is to implement a VetoableSelectionModel similar to a bean with a vetoable property: on selection change it queries registered VetoableChangeListeners if they don't object and backs out if one of them barks.
    HTH
    Jeanette

  • How to stop JList selection?

    Hi,
    Is it possible to stop the JList box selection? i.e. keep the selection at the old selection. I tried the following in the ListSelectionListener valueChanged() method:
    if (e.getValueIsAdjusting()){
    // Do something to the old selection
    // if something is wrong,
    list.setSelectionInterval(old_index, old_index);
    else {
    // do something to the new selection.
    But this is actually REVERTing the selection, but not STOPPing the new selection. Since it is in the valueChanged() method, I guess there is no way I could STOP the selection here.
    Does anybody know where and how to "veto" a list selection event? Note that this will be triggered by user's mouse click on the list box.
    Thanks!

    You'll have to do it in a new thread, try the SwingUtilities.InvokeLater method like this:
       if (e.getValueIsAdjusting()){
    // Do something to the old selection
    // if something is wrong,
           list.setSelectionInterval(old_index, old_index);
       } else {
           SwingUtilities.invokeLater(new Runnable() {
              public void run() {   
    // do something here
       };o)
    V.V.

  • Not able to reach start of selection event in the called program

    hi,
    I have a report 1 in which i am calling report2 using below syntax,
    SUBMIT Report2  VIA JOB gv_jobname NUMBER gv_jobcount
                 WITH s_g_yr  IN s_g_yr
                 WITH s_c_rf  IN s_c_rf
    AND RETURN.
    the problem is when report 2 is called it exists after event "at selection screen output" and does not go in the event "start of selection". 
    Please advise. how can i reach the "start of selection" event where all the processing logic is specified..
    Thanks and Regards,
    Kriti

    Hi,
    In your report you have used the event AT SELECTION-SCREEN OUTPUT. So, first it will trigger this event and then it will go for START-OF-SELECTION event.
    Events will trigger in this following way.
    LOAD PROGRAM
    INITIALIZATION
    AT SELECTION-SCREEN
    AT SELECTION-SCREEN OUTPUT
    START-OF-SELECTION
    END-OF-SELECTION
    TOP-OF-PAGE
    END-OF-PAGE
    In above sequence events will trigger in report.
    Regards,
    Shankar.

  • [JS/CS4/CS5] Catching a selection event in a ScriptUI interface.

    I've got this ScriptUI interface (javascript based), and now I wonder if it would be possible to change one of its button captions depending on whether anything is selected or not, in the active document (would also have to be updated if the user selects or opens another document).
    1. Is it possible to write event listeners for this?
    2. Would it be possible to include this in the same script as the rest of the Script UI interface code (that is, I'd prefer avoiding a separate file in the startup folder).
    3. What's the best source of information regarding events, which ones there are, and how to handle them in javascript?
    Andreas

    1. Yes. The selection events work well in my experience.
    2. Yes, you don't have to add them at startup. You can do something like:
    app.addEventListener("afterSelectionChanged", selectionChangedFunction);
    before you open your window. Remove the listener in the onClose event of the window. I think you'll have to have some error trapping in the selectionChangedFunction to deal with app.selection erroring after a document close or during a revert.
    3. See this thread for an extension that lets you see events as they're happening.
    Jeff

  • Finding selected event in iCal

    I want to run a script that processes the currently selected iCal event / todo. (sync it with a Filemaker DB).
    I cant find a command that returns the selected/current/active iCal object. I can only find an object one with a given property value.
    I'm a bit new to this so any pointers would be greatly appreciated.
    OTBC

    Hi OTBC,
    I was waiting for someone to post something Apple maight have added in newer versions of iCal, but I guess they didn't add anything.
    There is no selection property in iCal, but you can create macro like statements to script applications. So, as a wrokaround in iCal, you could use keystrokes to get the name of the currently selected event.
    tell application "iCal" to activate
    tell application "System Events"
    tell process "iCal"
    keystroke return
    keystroke "c" using command down
    end tell
    end tell
    This would copy the summary of to selected event. You could tab to tab through the information for the event. This might help you pinpoint the event in the case where there are several events with the same summary. Like a macro you would have to test it out in iCal to find the right combination of keystroke and ui scripting.
    Note that it is very hard to get recurrence events.
    gl,

  • Since I upgraded to Yosemite I can no longer upload photos to eBay by selecting "events"  all my photos pop up together.  Anyone know how to fix this?

    I recently updated to Yosemite 10.10.1.  Since I updated I can no longer upload photos to eBay, Shutterfly, Craigslist by selecting "events".  It is no longer an option.
    All my photos come up as one entire library.  When I view them in iPhoto they are divided into events, however once I go to upload them the entire library appears without any defining options, such as "events", recent imports, etc.   I thought at first this might be an issue with eBay, but realized it wasn't when I tried to list on Craigslist.  This is a nuisance and time consuming process.  Does anyone know if there is a fix in the future or if I am just missing some quick fix?

    I would like to add that Comcast is my internet provider. Perhaps that is part of the issue although the Connection Doctor confirms the mail box is connecting to the internet. No other function processes when Connection Doctor program is used to find the source of the issue. I have read forum posts but am unable to find a way to get my Apple mail to be delivered to my computer. It worked fine up until I chose to transfer mail to the Cloud. My mail account is a .mac account.
    Still hoping someone out there can help me.
    thanks,
    anne

  • Error in at line-selection event...

    Hello experts,
    In my report, I am hiding the values of BUKRS, ANLN1 and ANLN2 during my loop.
    I am using field symbols as my work area for my itab which is it_output. The problem
    is, when I try to do this in my at line-selection event:
    at line-selection.
    data: cursorfield(20) type c.
        get cursor field cursorfield.
        case cursorfield.
         when '<FS_OUTPUT>-ASSET_SUBNUM'.
         SET PARAMETER ID 'BUK' FIELD <FS_OUTPUT>-bukrs.
         SET PARAMETER ID 'AN1' FIELD <FS_OUTPUT>-asset.
         SET PARAMETER ID 'AN2' FIELD <FS_OUTPUT>-anln2.
        endcase.
    It says that it can't recognize the fields. What am I doing wrong? By the way, I am using
    ABAP Objects in my report. Help would be greatly appreciated. Thanks again guys and take care!

    Hi Viraylab,
    Have you assigned the fieldsymbols ?
    ASSIGN IT_OUTPUT to <FS_OUTPUT>.
    Cheers
    VJ
    Message was edited by: Vijayendra  Rao

  • Using select event for interlayer navigation

    Hi All,
                  I have two tables. The output of first table is input for the second one. When I select a row in the first table,the SELECT event is fired and the second table is populated based on the selection.
                 Now I have a scenario where the two tables are on separate layers. My requirement is that, the secondlayer should be brought in when the SELECT event is fired. I don't want to use a button to trigger a navigation event. I try naming the navigation event as SELECT but it didn't work.
         please help

    Hi Jarrod,
              Yes your view i sright. But i had mistakingly mentioned a table. Its Bar chart actually. When a bar is clicked, second layer should appear with the detail table ouput.
          Though the table is filled with the click but the navigation is not happeneing. Do you have any idea abouit it ?
    I have used *select also but to no avail

  • Select event not triggered in table with only one row

    Hi all,
    I am building a BI VC application where query data is displayed in a table. When the user clicks on a table row another query is then triggered and output in a second table. The output from table 1 is linked to the input of query2/table2 with a select event.
    The problem that I am facing is that if there is only one row in table 1, the select event is never triggered. If, however there are two or more rows in the table the select event is triggered and query 2 is executed. I have searched the forums but all I could find on select event problems was how to avoid the initial select event.
    Has anyone else experienced this issue and what is the workaround or is this a bug in Visual Composer? We are on VC 7.0 SP19.
    Cheers,
    Astein Meland

    Thanks Chittya,
    Yes we have considered this option as well. But as we have more than one table linked together we would like to avoid having to manually click several buttons.
    In the end I found Note 1364334 describing bugfixes released in VC 7.0 SP20:
    "Normally, when a Visual Composer table is populated from a data service, the first row is selected by default. However, we have found that if only one data row is returned from the data service, this row is not selected by default and cannot be manually selected by clicking on it either."
    So I think we will just have to upgrade our Portal to the latest support packs to solve this problem.
    Thanks,
    Astein

  • What is the use of "end of selection" event in report

    Hi all
    As we can display the outputs in the "start-of-selection "using the write statement.
    Then what is the use of "end-of-selection" in reports.
    Please tell me with some real tiem examples.
    God points will be rewarded.
    Thanks

    Hi,
    The END-OF-SELECTION event is triggered in type executable programs once the logical database has finished reading all data and before the list processor is started.
    It tells the server that all the database reading is completed and no further reading is going to take place..
    For more details go through the following link:
    http://help.sap.com/saphelp_me21sp2/helpdata/en/9f/db9aca35c111d1829f0000e829fbfe/content.htm
    END-OF-SELECTION is used mostly when you are using Logical data base in your report. It is triggered when all selection get finished from the data base.
      You can use write statments in start of selection and end of selection also.
      But the one use of end of selection is... if you want to stop the processing of a certain code and directly display some message you can use this.
    start-of-selection.
      select data..
      process data
    if no data .
    stop.
    endif.
    write data
    end-of-selection.
    write : 'No data to display.
    Stop command will take the control to end of selection event.
    thanks,
    mahesh
    Message was edited by:
            I Can Solve It

  • Proper use of END-OF-SELECTION event in report programme

    Hi,
    If we will write "WRITE" statements in side START-OF-SELECTION then it will help me to display the output.Then what is the need of END-OF-SELECTION .
    Can any body please tell me the <b>proper use of END-OF-SELECTION event in report programme.</b>

    This is the last of the events called by the runtime environment to occur. It is triggered after all of the data has been read from the logical database, and before the list processor is started.
    <b>In report programs using LDB for every value selected the program issues the output, to control this you would use END-OF-SELECTION.</b> Now if you call your output in this event, the output is made only after all the values are selected as per the selection criteria.
    suppose while coding, u need a logic like below:
    if a condition is satisfied continue with the report
    and if not satisfied, then display a message and end the report.
    then u can code like below.
    start-of-slection.
    if a = <condition>.
    do the following.......
    else.
    stop.
    end-of-selection.
    write: 'THIS IS END'.
    stop command triggers end-of-slection from anywhere.
    I hope it helps.
    Best Regards,
    Vibha
    *Please mark all the helpful answers

  • "AT LINE-SELECTION" event in a Query (SQ01 or SQ02)

    Hi there
    I want to know if it's possible to put "AT LINE-SELECTION" event in an ABAP Query? I'm trying that in SQ02 - the infoset - but nothing happens when I double-click on the output lines. I cannot find any place to type codes in SQ01.
    The purpose is to call a transaction VA03 when people double-click on the output field "sales order number" and here is the code I put in "Free coding" section of SQ02.
    AT LINE-SELECTION.
      DATA: w_cucol TYPE sy-cucol.
      w_cucol = sy-cucol + sy-staco.
      w_cucol = w_cucol - 2.
      IF w_cucol BETWEEN 103 AND 119.
        SET PARAMETER ID 'AUN' FIELD vbkd-vbeln.
        CALL TRANSACTION 'VA03' AND SKIP FIRST SCREEN.
      ENDIF.
    yu

    Hi ,
    You must create infoset based on join VBKD with VBAK and LIPS.
    Also you must put VBAK-VBELN and LIPS-VBELN as a column output.
    There is no problem to use 2 report assignment ( there is no loss ).
    There is no necessity to use " some ABAP code at line-selection ".
    This works.
    By the way is more correct from the beginning to formulate the issue including all the data about your problem and not include them by adding a little at a time.
    Regards.

Maybe you are looking for