Selected item in a JList - Clear selection after mouse click

Hello:
I'm developing a Java GUI application which uses some JLists. I've seen that, when an item of the JList is selected and you click the mouse another time in the same selected item, the selection does not "disappear". Now, the only way I know to do this is tho press Control + click in the selected item.
I would like that, when I click to the selected item of a list, the selection disappears.
How can I solve that?
Lots of thanks for your help.

add a MouseListener to the list
in mouseReleased (note: Released), get the selected index
compare to previous selection - if the same, list.clearSelection()
if you clear the selection, you'll need to reset the 'previous selection' variable

Similar Messages

  • How do you select an item from a table indicator with a mouse click and then use that selection in code?

    Hi,
    I am displaying a list of filesfrom a directory  in a table on the front panel of a VI as part of a program I am developing. I would like the user to be able to select from that table so that particular file can be processed. Is there a way to do this?
    Thanks,
    Aaron

    you'll find that most of the useful functionality of the labview user control interface is hidden within the property node and invoke node functions. just right click a control or indicator terminal on the block diagram and mouse over to create, then to property node or invoke node. lots of fun stuff in there. attached is an example. one file is saved for labview 8.0, the other is saved for labview 8.6.
    Message Edited by Root Canal on 10-16-2008 11:17 AM
    global variables make robots angry
    Attachments:
    file selection table.vi ‏26 KB
    file selection table lv 8.0.vi ‏42 KB
    file selection table.PNG ‏18 KB

  • Focus not in item navigated to after mouse click

    Hi,
    We have moved a custom Form from 6i to 10g. This form works perfectly fine in the older instance.
    However, in R12 we're facing this problem.
    When the form opens, the control is on a radio group which has 3 buttons, one of which is hidden. The hidden button is the one that is selected by default. This is to done so that none of the displayed radio buttons are selected by default and the user is forced to select one. Only when he does so, he can proceed to enter the remaining fields.
    There is a text item attached to an LOV which is the first text item on this form next to the radio group. The WHEN-NEW-ITEM-INSTANCE trigger for this text item checks if one of the visible radio buttons have been selected, if not, it throws a message to select one and the focus goes back to the radio group.
    However, in R12, when I click on the text item, the WHEN-NEW-ITEM-INSTANCE trigger does not fire at all. When I check in diagnostics, the control is still on the radio button, even though the cursor shows it is on the text field. Thus when I try to click on the LOV for the text field I get a "Field does not understand operation error" as the focus is not really on the text field.
    If I tab out, then the focus DOES go to the text item and the WHEN-NEW-ITEM-INSTANCE trigger fires, displaying the message as expected. But again, the cursor is still positioned on the text item and not on the radio group. This may prompt the user to click on the LOV field again for the text item.
    Since the same code works perfectly fine in our 11.5.9 instance, i was wondering if this is a problem related to R12?
    Has anyone faced a similar problem? Any pointers in this regard would be greatly appreciated.

    Hi Pavan,
    Thanks for your suggestions. I figured the solution to my problem. The problem is in 10g, go_item will not work if we're trying to navigate to a disabled or hidden item. In my case, since go_item was trying to navigate to a radio button which was hidden, it wasn't working. This used to work in the earlier releases.
    I will have to modify the logic accordingly.
    Thanks.
    Edited by: Shruti Shetty on Feb 27, 2009 8:40 AM

  • Itunes search pop-up not selectable by mouse. (clicking selects objects in main window).

    When making a search, the window pop-up can not be selected by the mouse. It stays there, but any click results in selecting the main window (for example the normal song list). Even when just highlighting the mouse over the pop-up you can see the active window for the mouse is the main window because the icons that appear when hovering a song show for the main window only.
    Any ideas how to fix it?
    Specs:
    Windows 7 Ult.
    Itunes 11.0.5.5 (the latest).

    No luck. Even with newer updates, the issue still persist. Also, I have found about 4-5 other threads with the same issue that have popped up and not one has an answer.

  • Show Jbutton Selected on mouse click

    Hi,
    i am creating lines with jbutton. lines are very small. When user clicks on the lines i want to show them selected(somehow).I can't increase their border bcoz if user will copy them then they will be copied with that border is there any other way to show button selected and whenever use click somewhere(on applet, textfield or another jbutton) else delselect that jbutton.
    Thanks

    I have experiecnce with this problem... and unfortunatly ther's not solution.
    Some trigger (like when-mouse-enter or when-mouse-live) don't work with form deployed on web. I suppose that these triggers are not supported in deployd on web because the "client" browser shuld be constantly comunicate with the runtime engine.

  • By default a item in a JList should selected

    Hi
    I need a item in the JList should be selected(not the first item) by default while I am creating a new instances for the JList.
    Note: I am rendering a button in the JList.
    with regrads
    senthil kumar

    You should be able to use either of the following methods of JList: setSelectedIndex(defaultIndex); or setSelectedValue(defaultObject, shouldScroll);Is one of these what you are looking for?

  • Programatically Select an Item in a JList

    Hi,
    I need to do this: Programmatically select an item in a JList.
    JList.selectItem(0) will select the item 0 in the model but it will NOT visually highlight the selected item in the list.
    Neither will ensureIndexIsVisible(0),
    I need to automatically select and item in a list (highlight that item as well)
    As if someone has clicked on that item with the mouse.. however they haven't you see, my program has done it, programatically.
    Please don't refer me to the beginners guide to java, or the API documentation, the answer is not there.
    Thanks

    Swing related questions should be posted in the Swing forum.
    Please don't refer me to the beginners guide to java, or the API documentation, the answer is not there.Yes it is.
    If you need further help then you need to create a [url http://homepage1.nifty.com/algafield/sscce.html]Short, Self Contained, Compilable and Executable, Example Program (SSCCE) that demonstrates the incorrect behaviour, because I can't guess exactly what you are doing based on the information provided.
    And don't forget to use the [url http://forum.java.sun.com/help.jspa?sec=formatting]Code Formatting Tags so the code retains its original formatting.

  • Can you eliminate an item from a drop down menu after it is selected once so it isn't selected again

    Can you eliminate an item from a drop down menu after it is selected once so it can't be selected again be someone else?

    I am sorry but Formscentral doesn't support any type of dynamic form content updating.
    Andrew

  • Since I installed the new version 17.0.1, third party cookies will not stay selected after I close the browser...

    Simply -- third party cookies will not stay selected after closing the browser and I have to select it for each time to use certain cookies from websites...

    You may need to create an allow exception to keep specific cookies.
    *http://kb.mozillazine.org/Cookies
    In case you are using "Clear history when Firefox closes":
    *do not clear the "Cookies" and the "Site Preferences"
    *Tools > Options > Privacy: History: [X] Clear history when Firefox closes > Settings
    *https://support.mozilla.org/kb/Clear+Recent+History
    Note that clearing "Site Preferences" clears all exceptions for cookies, images, pop-up windows, software installation, and passwords.

  • Select item with Right Mouse Click

    hello, this is a pretty simple idea: i want to be able to have an item in a JList be selected when i RIGHT click on it, not just left click.. i want to do this because i have a popup menu come up, but i also want the item that the mouse is over to be selected, so the user doesnt have to left click an item, then right click...
    im pretty sure theres a way to do this.. i looked through documentation, but had no luck.. thanks a lot,
    Steven Berardi
    ------------------------

    hi,
    combobox.addMouseListener(this)
    public void mouseClicked(MouseEvent e)
    if(me.getModifier()==MouseEvent.BUTTON3_MASK)//rechte Maus
    String item=combobox.getSelectedItem();
    implement the other methods for interface mouselistener

  • DataGrid data can not be selected after inlcluded automation library

    In order to use QTP for my Flex project, I included the automation libraries.
    But I found that the data in DataGrid can not be selected, and double click function not working.
    After I excluded the following two of the automation libraries, it works fine.
    automation_agent.swc
    qtp.swc
    FLex SDK version:  4.1.0.16076
    Anyone can help?

    It occurred to me that this might be a permissions problem - I had repaired permissions using TechTool Pro a few days ago and that may have caused this - who knows!
    Anyway, I'm just re-repairing permissions using Disk Utility. It says 'Estimated Time: 3 hours' which considering previous permissions repair seems a long time - maybe that is an indication of the problem.
    I'll post again in 3 hours!

  • Row doesn't get selected after sorting

    I have a table bond to a javabean data control. I have enabled multi row selection. I get some rows on the table and then I select one of those rows, after that I use the value of the selected row for some operations.
    I have 3 columns, first name, lastname , email. The first 2 are sortable. If I click on the header of firstname, the information gets sorted ok (asc / desc). The problem is that after sorting, I can NOT select any rows. When I click on the row, it doesn't get highlighted, and If I try to use the value of the selected row I get a null pointer exception.
    Again this is happening only after sorting. If I don't sort, it works ok.
    I'm using JDEV + ADF 11.1.1.5.
    This is my code
    <af:table value="#{bindings.User1.collectionModel}" var="row" partialTriggers="::cb1"
    rows="#{bindings.User1.rangeSize}"
    emptyText="#{bindings.User1.viewable ? identityBundle.no_data_to_display : identityBundle.access_denied}"
    fetchSize="#{bindings.User1.rangeSize}" rowBandingInterval="0"
    id="t1" rowSelection="multiple"
    selectionListener="#{AssignRolesBean.onTableSelect}"
    binding="#{AssignRolesBean.searchResultsTable}"
    columnStretching="last">
    <af:column sortProperty="firstname" sortable="#{AssignRolesBean.columnSortable}"
    headerText="#{bindings.User1.hints.firstname.label}" id="c1"
    width="136">
    <af:outputText value="#{row.firstname}" id="ot4"/>
    </af:column>
    <af:column sortProperty="lastname" sortable="#{AssignRolesBean.columnSortable}"
    headerText="#{bindings.User1.hints.lastname.label}" id="c2"
    width="182">
    <af:outputText value="#{row.lastname}" id="ot2"/>
    </af:column>
    <af:column sortProperty="mail" sortable="#{AssignRolesBean.columnSortable}"
    headerText="#{bindings.User1.hints.mail.label}" id="c4"
    width="361">
    <af:outputText value="#{row.mail}" id="ot5"/>
    </af:column>
    <af:column sortProperty="uid" sortable="false"
    headerText="#{bindings.User1.hints.uid.label}" id="c3"
    visible="false">
    <af:outputText value="#{row.uid}" id="ot3"/>
    </af:column>
    </af:table>
    I have a selection listener only, I don't have a sort listener.
    My bean;
    AssignRolesBean
    public void onTableSelect(SelectionEvent selectionEvent) {
    GenericTableSelectionHandler.makeCurrent(selectionEvent);
    My makeCurrent method
    public static void makeCurrent( SelectionEvent selectionEvent){
    RichTable _table = (RichTable) selectionEvent.getSource();
    CollectionModel tableModel = (CollectionModel) table.getValue();
    JUCtrlHierBinding adfTableBinding = (JUCtrlHierBinding) tableModel.getWrappedData();
    DCIteratorBinding tableIteratorBinding = adfTableBinding.getDCIteratorBinding();
    Object selectedRowData = table.getSelectedRowData();
    JUCtrlHierNodeBinding nodeBinding = (JUCtrlHierNodeBinding) selectedRowData;
    Key rwKey = nodeBinding.getRowKey();
    tableIteratorBinding.setCurrentRowWithKey( rwKey.toStringFormat(true));
    SHOULD I IMPLEMENT A SORT LISTENER FOR THIS TABLE IN ORDER TO HANDLE ROW SELECTION PROPERLY AFTER SORTING?
    Is there a guideline for handling row selection after sorting?
    Thanks

    I have a table bond to a javabean data control. I have enabled multi row selection. I get some rows on the table and then I select one of those rows, after that I use the value of the selected row for some operations.
    I have 3 columns, first name, lastname , email. The first 2 are sortable. If I click on the header of firstname, the information gets sorted ok (asc / desc). The problem is that after sorting, I can NOT select any rows. When I click on the row, it doesn't get highlighted, and If I try to use the value of the selected row I get a null pointer exception.
    Again this is happening only after sorting. If I don't sort, it works ok.
    I'm using JDEV + ADF 11.1.1.5.
    This is my code
    <af:table value="#{bindings.User1.collectionModel}" var="row" partialTriggers="::cb1"
    rows="#{bindings.User1.rangeSize}"
    emptyText="#{bindings.User1.viewable ? identityBundle.no_data_to_display : identityBundle.access_denied}"
    fetchSize="#{bindings.User1.rangeSize}" rowBandingInterval="0"
    id="t1" rowSelection="multiple"
    selectionListener="#{AssignRolesBean.onTableSelect}"
    binding="#{AssignRolesBean.searchResultsTable}"
    columnStretching="last">
    <af:column sortProperty="firstname" sortable="#{AssignRolesBean.columnSortable}"
    headerText="#{bindings.User1.hints.firstname.label}" id="c1"
    width="136">
    <af:outputText value="#{row.firstname}" id="ot4"/>
    </af:column>
    <af:column sortProperty="lastname" sortable="#{AssignRolesBean.columnSortable}"
    headerText="#{bindings.User1.hints.lastname.label}" id="c2"
    width="182">
    <af:outputText value="#{row.lastname}" id="ot2"/>
    </af:column>
    <af:column sortProperty="mail" sortable="#{AssignRolesBean.columnSortable}"
    headerText="#{bindings.User1.hints.mail.label}" id="c4"
    width="361">
    <af:outputText value="#{row.mail}" id="ot5"/>
    </af:column>
    <af:column sortProperty="uid" sortable="false"
    headerText="#{bindings.User1.hints.uid.label}" id="c3"
    visible="false">
    <af:outputText value="#{row.uid}" id="ot3"/>
    </af:column>
    </af:table>
    I have a selection listener only, I don't have a sort listener.
    My bean;
    AssignRolesBean
    public void onTableSelect(SelectionEvent selectionEvent) {
    GenericTableSelectionHandler.makeCurrent(selectionEvent);
    My makeCurrent method
    public static void makeCurrent( SelectionEvent selectionEvent){
    RichTable _table = (RichTable) selectionEvent.getSource();
    CollectionModel tableModel = (CollectionModel) table.getValue();
    JUCtrlHierBinding adfTableBinding = (JUCtrlHierBinding) tableModel.getWrappedData();
    DCIteratorBinding tableIteratorBinding = adfTableBinding.getDCIteratorBinding();
    Object selectedRowData = table.getSelectedRowData();
    JUCtrlHierNodeBinding nodeBinding = (JUCtrlHierNodeBinding) selectedRowData;
    Key rwKey = nodeBinding.getRowKey();
    tableIteratorBinding.setCurrentRowWithKey( rwKey.toStringFormat(true));
    SHOULD I IMPLEMENT A SORT LISTENER FOR THIS TABLE IN ORDER TO HANDLE ROW SELECTION PROPERLY AFTER SORTING?
    Is there a guideline for handling row selection after sorting?
    Thanks

  • YAB - FM11 Find/Change using Selection drops selection after first find

    Yet another bug in FM11?
    If you are using a selection to limit the scope of a find/change, FM11 now drops the selection after the first find.  Consequently, it can't find anything else that matches as there is no more selection and you have to re-select again. What a PITA!
    In FM10 and earlier, FM would remember the selection and just keep searching until it reached the end of the selection.
    Can anybody verify this user-hostile (what's a QC test script?) behaviour in the latest pached version of FM11?

    I just changed modes in FM11 from strructured to unstructured. The problem does NOT occur in unstructured FM!

  • How do you change your intial bc template selection under site options after you click finish

    how do you change your intial bc template selection under site options after you click finish

    You cant. BC doesnt have a theming system like Wordpress or Joomla. The template is fixed and switching templates at this stage is not an easy feat.

  • (1) Is there any way that I can get the transition menu to remain on the screen. I select a transition, drag it to the timeline and after I click done I have to start the process all over to perform this action on the next transition. I have premiere elem

    (1) Is there any way that I can get the transition menu to remain on the screen. I select a transition, drag it to the timeline and after I click done I have to start the process all over to perform this action on the next transition. I have premiere elements 12. In older version the menu would stay on the screen.
    (2) In pan and zoom how can start zoom on a photo in the original picture and zoom in and the next picture zoom out and the next photo pan from right to left and the next photo pan left to right.
    Thanks
    Sam

    TidyCup
    What computer operating system is your Premiere Elements 12 running on? If you have not already, be sure to update 12 to 12.1, using an opened project's Help Menu/Update.
    But to the immediate questions, assuming Windows 7, 8, or 8.1 64 bit....
    1. No, it is what it is. But, are you applying the same transition each time? If so, then highlight/select all the clips involved (all at one time), then Timeline Menu/Apply Default Transition will do just that for the highlighted/selected clips.
    To highlight/select more than one clip at a time, hold down the Shift key of the computer main keyboard and then click on each clip that you want in the group selection
    or
    with your mouse cursor draw a rectangle around the clips that you want to select
    2. Are you using the Premiere Elements 12/12.1 Expert workspace Pan and Zoom Tool? Or the pan or zoom presets under fx Effects/Presets/? With those you can do pan or zoom, not pan and zoom.
    Or, are you in the Elements Organizer 12 Slideshow Editor using the pan and zoom effect there? Or, are you using keyframing the Motion Scale property for zoom and the Motion Position property for pan?
    Are you asking about photos with landscape or portrait orientation?
    The pan and zoom tool does one photo at a time.
    Have you read the Adobe documentation on the Pan and Zoom Tool?
    http://help.adobe.com/en_US/premiereelements/using/WSeffff8bffc802084-494411db12fd35452dd- 8000.html
    Please review and clarify and then we can get into greater details on this.
    Thanks.
    ATR

Maybe you are looking for

  • System trace for File, JDBC adapter

    In the  JDBC Adapter Help (help.com) I see: „The adapter writes the output (STDOUT and STDERR) for the operating system command in the system trace.” Which trace is meant here? I have the same question regarding File Adapter. Thanks, Jozsef

  • Title bar vanishes in gnome when chaning sound preferences

    Hi all, A very strange problem occured to me today. In System -> Preferences -> Sound -> Sounds when I toggle "Play alerts and sound effects" the titlebar of all windows are gone! Also keyboard shortcuts don't work anymore at this point. The xsession

  • Why am I getting 'cannot connect to iTunes store' message when going to App Store?

    I recently purchased a refurbished iPad 1 (iOS 5.0) from the Apple Store.  I've downloaded one free app from the App Store.  But today when I returned to the App Store, the following message displayed:  Cannot connect to iTunes store. I have an Apple

  • CS5 DW Spell Checker

    I get an error message that says "The spell checker could not be initialized." How do I fix that?

  • Win XP Serv Pk 3 "Limited or no Connectivity" Error on Ethernet and Airport

    Hi, I have a 2009 MacBook Pro (dual boot) with a fresh install of Windows XP, SP3 and Boot Camp drivers. But I can't get it to work properly with any other computer on a network, connected via ethernet or wifi. I have a "Limited or no Connectivity" m