JComboBox - delaying the dropdown list

Does anyone know how to delay the population of a JComboBox's list until the user clicks the down arrow?
In effect:
1) the user clicks the arrow on the comboBox
2) the wait cursor appears (no drop-down yet)
3) the list gets built (still no drop-down)
4) the data retrieval is done, the drop-down list is then shown, and the cursor returns to normal

The size of the popup is based on the number of elements in the
combobox before the model was rebuilt. We need to reset the popup
when the number of items in the combobox changes.That seemed to do the trick. I don't know what I was trying originally before I posted for help, but when I called hidePopup() or showPopup() from within the popupMenuWillBecomeVisible() method, I was getting a stacktrace out the wazoo.
Thanks for all of the ideas. Here's a completed example in case someone wants to refer to this later. I even added a sleep() call in the rebuildList method to simulate a long transaction, so that you can see the effect of the delay:
import java.awt.*;
import java.awt.event.*;
import java.util.*;
import javax.swing.*;
import javax.swing.event.*;
public class DelayedComboBoxTest extends JFrame
  private JCheckBox chkA = new JCheckBox("A");
  private JCheckBox chkB = new JCheckBox("B");
  private JCheckBox chkC = new JCheckBox("C");
  private JComboBox cboItems = new JComboBox();
  public DelayedComboBoxTest()
    super("Delayed ComboBox Test");
    setDefaultCloseOperation(EXIT_ON_CLOSE);
    JPanel p = new JPanel();
    p.add(chkA);
    p.add(chkB);
    p.add(chkC);
    p.add(cboItems);
    Container c = getContentPane();
    c.setLayout(new BorderLayout());
    c.add(p);
    pack();
    cboItems.addPopupMenuListener(new MyPopupMenuListener());
  private void rebuildList()
    setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
    Vector items = new Vector();
    if (chkA.isSelected()) { items.add("A"); }
    if (chkB.isSelected()) { items.add("B"); }
    if (chkC.isSelected()) { items.add("C"); }
    cboItems.setModel(new DefaultComboBoxModel(items));
    try
      new Thread().sleep(1500); // simulate a long transaction
    catch (InterruptedException ex) {}
    setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
  public static void main(String[] args)
    JFrame f = new DelayedComboBoxTest();
    f.setVisible(true);
  class MyPopupMenuListener implements PopupMenuListener
    public void popupMenuCanceled(PopupMenuEvent e) {}
    public void popupMenuWillBecomeInvisible(PopupMenuEvent e) {}
    public void popupMenuWillBecomeVisible(PopupMenuEvent e)
      int items = cboItems.getItemCount();
      rebuildList();
      if (items != cboItems.getItemCount())
        cboItems.hidePopup();
        cboItems.showPopup();
}One downside though: typically, a change in one of the trigger fields' content (the 3 checkboxes in this case) would cause the list to be rebuilt. It's there where you can check to see if the previously selected item in the list is contained in the new list. If so, reselect it, otherwise clear the selection. In other words, if the old value is still valid, keep it selected.
In this new way, the old value remains selected even if it's logically bad. On save, one would have to query if the selected value is still valid based on the criteria of the other trigger fields. Yeah, it's an extra step, but I don't mind doing an inexpensive hit once (on save) rather than an expensive one several times as each of the trigger fields is changed (of which could be many)

Similar Messages

  • How to get the keys for a field in the dropdown list?

    The dropdown list of payment terms on an account is unfortunately very big, containing al lot of different values, in our system and therefore very confusing for the user working with Web UI version 5.2 to pick the right one. The keys (code like e.i Z077 or ZO23) are not stated in the list available for user. Is there any way in the system to flag if the different fields should show boths the keys(codes) and the description of the values in the field as Payment terms, etc.
    In the ERP SAP Gui it is possible to activate if you want the keys should be shown in all drop down list.
    If this is not possible for all the fields at one time, what can be a solution to have the keys in the drop down lists, any suggestion will be very valuable for us.
    Kindly regards
    Camilla

    HI Joost
    No it is not that simple, that is not a solution for us. The fields are maintained i our backend system and replicated to CRM, and these fields descriptions are also printed at Order confirmations and invoices, and we do not want the keys that do not give any meaning  to be visible to customers.
    BR
    Camilla

  • How to fill the dropdown list in a input field

    Hi all,
    I have three input fields, Month, Material type and material.
    My requirement is to search material based on material type.  So if i select one material type from the dropdown list, corresponding material should be populate in the material dropdown.
    Pls suggest to this requirement i have
    Regards
    Jeswin

    Hi,
    Refer Below Blog Step By Step For fill data in dropdownlist Getting Data From SAP BI Systems.
    Visual Composer :Get drop down list values  from BI InfoObject master data
    The Below Link is the For getting data from SAP ECC Systems For Both Value Help And DropDown list.
    Visual Composer: Value Help Data Service
    Go Through Above Links
    Points Are Welcome
    tahnks
    SubbaRao Chinta

  • By selecting the dropdown list a new empty browser tab is getting opened

    Hi,
    When i try to pass the parameters in Bi report, by selecting the dropdown list a popup(new empty browser tab) is getting opened why is this so. Can anyone help me to sort it out.
    Edited by: user9093700 on Jul 6, 2012 8:57 AM
    Edited by: user9093700 on Jul 9, 2012 8:46 AM

    If you have tabs on top and no menu then the tabs are in a "Windows" area so there is no space to right. If you put tabs back to the bottom you will have most of your old behavior but because of the changes to tabs on top most of the tab context menu stuff all of the context menu part was lost except the customize toolbar stuff, double-clicking on an empty spot was restored, and eventually during the FF 4 beta most of the tab extensions Firefox messed up eventually worked again except in the area to the right of the tabs.
    The Windows part of that double-click has to maximize or restore to normal,
    and you have to be able to drag the window by it;'s title bar.
    You can make Firefox 4.0.1 and '''Firefox 5.0''' look like Firefox 3.6.17, see numbered items 1-10 in the following topic [http://dmcritchie.mvps.org/firefox/firefox-problems.htm#fx4interface Fix Firefox 4.0 toolbar user interface, problems (Make Firefox 4.0 look like 3.6)]

  • How to Display a Calender upon clicking the dropdown list inside a table co

    Hi,
    I have a Listbox inside my table control and I need to Display a Calender upon clicking the dropdown list.
    Can any body help.
    Srinivas

    Hi,
    Try this:
    On your customizing screen,
    PROCESS ON VALUE-REQUEST.          
        Field T_ZT-SDATE
          module create_dateselect.
    In your main program:
    module create_dateselect.
    data:p_date like sy-datum.
    CALL FUNCTION 'F4_DATE'
       EXPORTING
         holiday_calendar_id = 'CN'                   
         display = ' '
       IMPORTING
         select_date = p_date
       EXCEPTIONS
         OTHERS = 4.
    t_zt-sdate = p_date.
    endmodule.
    Regards,
    Pole

  • The dropdown list in the address bar does not work when clicked

    In the address bar the dropdown list icon does not work when clicked. I have tried resetting everything in safemode and it still doesn't work. When I click on the icon it just highlights the entire address line.

    This can be a problem with the file places.sqlite that stores the bookmarks and the history.
    * http://kb.mozillazine.org/Bookmarks_history_and_toolbar_buttons_not_working_-_Firefox
    Also check the setting in:<br />
    [http://kb.mozillazine.org/Menu_differences Firefox > Preferences] > Privacy > Location Bar: When using the location bar, suggest: History, Bookmarks, History and Bookmarks

  • Why has the dropdown list of search engines changed from a straightforward list to a field of indistinguishable icons?

    Until the most recent update the dropdown listing of available sites in the search box was easily legible and simple to use. Being able to target one's searches so readily and conveniently was one of Firefox's most attractive features.
    Now I'm confronted with a panel of mostly indecipherable and in many cases confusingly similar icons. I hate it and want my simple verbal listing back!
    Yes, mousing over the icons and hovering will reveal what they represent. But having to do this every time makes what was a quick, convenient routine irritatingly slow and clunky.
    Please at least let us choose whether to have icons or a simple listing. Please...

    Further to my initial query, I notice that the previous facility to click 'Manage Search Engines...', thus allowing you to rearrange or add to/subtract from available searches (all within the dropdown from the search box), has gone.
    Clicking 'Change Search Settings' now opens up a new tab in the main preferences panel -- and as far as I can see doesn't even allow reordering or permanent deletion of search items.
    Whoever thought this would be an improvement? It isn't!!!

  • I updated to 3.6, lost bookmarks, have only a default profile so I restored. The bookmarks are now there but I can't get the dropdown list for many folders so I can't access these. Clicking on the arrow to the right of the folder name does nothing.

    When I Click on some of the bookmark folders I do get a dropdown list of sites but not always all of the sites that were bookmarked. If I copy a nonresponding folder, the new copy can be accessed but apparently does not contain all of the sites. If I rightclick on a nonresponding folder and use 'open all tabs' Firefox will tell me the number of sites in the folder and ask if I really want to open so many.

    Sounds like a corrupted places.sqlite file.
    See http://kb.mozillazine.org/Locked_or_damaged_places.sqlite

  • Purchasing orgn not able to find in the dropdown list.

    Hi 
    Can anyone guide me I am not able find the new Purchasing groups in dropdown list of my basic date in while creation of shopping cart.
    I aslo created new company code and new Purchaisng Org , I am able to get the new company code and new plant in the drop down list but not able to find the Pur groups.
    Can any one help me on this, Because I have assigned the Org unit of Company code and Pur org also in the responsibility tab of this Pur grp.
    but still the problem persists.
    please suggest.
    Regards
    srujan.k

    Hi,
    Please check the user attributes in PPOSA_BBP.here you can see the user id is tagged to one purchase group.
    You can assign the user to one Purchase group,that's a reason you are not able to see the drop down list for purchase group while creating SC.
    If you want another purchase group, please change the user attributes.
    I hope it will help.
    Regards,
    Manish

  • Details not appearing in the dropdown list in the filter window

    Dear All,
       I have come accross a unique problem. I have made a user defined query. Now there is an item code column. I want to filter the item codes in the generated query. But all the items are not appearing in the filter window> item field> dropdown. My query output shows all the items but the filter does not!!!
       I have 10,000 items where the codes are ranged from A to X with various serials. When I run the query the report shows all the items which are within the query conditions. But when I open the filter window then in the dropdown for the item code only codes upto "G" appear.
       How can this be resolved?? otherwise I am not able to filter my selections.
    Regards,
    Raja

    hi suda,
    The query is to generate a report to find out the total units of items sold through delivery. Actually, there is no problem with the query. The query shows absolute reports. The problem is among these 10,000 items which come in the report, if I need to see some specific item then I can use the filter option. But in the filter option the items codes upto "G" are only appearing inspite of the fact that the query report list has all the items from A-J.
    I hope I am clear. This is not the problem with this query only. In all the queries where the item details are appearing, the system doesnot give me the flexibility to filter by all the items rather only upto a range. Why is it so?
    Still if you need to see the query then please let me know. I will put in the query statement.
    Regards,
    Raj

  • How do I get my brushes to show up in the dropdown list?

    I'm fairly new to Photoshop. I'm using CS6, and I'm having a little trouble. Mostly, I have a lot of brushes, but not all of them show up in the dropdown menu for brushes:
    So, how can I fix this, if there is a fix for this? Any help is much appreciated. Thank you!

    Is there a way to further divide brush sets into groups?  I agree that is an unmanagably long list, and I bet most of them are never used.  It looks like Windows 7, so the brushes live in
    C:\users\your user name\App Data\Roaming\Adobe\Adobe Photoshop CS6\Presets\brushes\
    I've never tried adding a folder to the brushes folder, but even if it is still recognised, I suspect it would not not change the look of that list.  I'll have a try though, out of interest.
    Here's an idea.  Find the above folder, and right click and send to desktop as shortcut, and place another shortcut to a master list of brushes right next to it.  Open both, and drag groups of brushes into and out of the brush folder on those rare occassions you need them.  Wouldn't it be nice if you could incorperate such a feature into a custom workspace?
    [EDIT]  Well I just tried, and Photoshop CC sees the contents of sub folders in the Brushes folder.  That would help with my weird little idea above, and while my brush list is nothing like the OP's, it is bordering on being too big to be comfortable.

  • Problem with dynamically loading the dropdown list from database

    Please help me,
    i am having a jsp page which contains a form
    with a textfield ,two dropdown list
    and a submit button
    when i select a list from first drop down, second drop down has to
    be loaded from the database dynamically according to the
    selected one in the first drop down.
    i gave onselect event for the first drop down and
    gave this one
    temp=first dropdown selected value
    self.location='currentfile+query='+temp;
    after this current page is reloading, but the already existing
    values in textfield and first selected value in drop down list is
    missing.
    how to solve this problem? and the rest of the problem. i mean
    loading the data into second drop down list.
    plz help me......

    in first <selcet> tag write Onchange and submit to the jsp then the values will return in second select box.

  • Option to use private browsing is missing in the dropdown list

    The option to use private browsing is missing in the dropdown listo I think this happened after I down loaded an app that was supposed to help me shutdown private browsing since I didnt know how to do it. I dont remember which app it was. But either way its gone now..

    Hi,
    Unfortunately Firefox doesn't have an option to open a private tab in the current regular window.
    You have to open a new private window for private browsing.
    You can read more here.
    https://support.mozilla.org/en-US/kb/private-browsing-browse-web-without-saving-info

  • How do I get rid of the dropdown list history on the location bar? I have tried changing several settings and all I have done is mess up my ability to open ZIP downloads.

    I wanted to clear the drop down suggestions/history list on the location bar so I went to Tools/Options and tried changing several settings. I could not get the results I wanted. Suggestions?
    I did get one unwanted result -- or maybe just a coincidence. I received an email with attached pictures in a ZIP format and I could not get the download to open. Suggestions?

    Tools > Options > Privacy > Location Bar: When using the location bar, suggest: Nothing
    See [[Smart Location Bar]]

  • Rooms are not showing up in the dropdown list unders MY ROOMS

    HI,
    I created a new room and assigned couple of users and assigned myself as owner to that room. When i go under euRole --> My Rooms --> "No Rooms Available" message is displayed. Even i pressed FILTER button with selection criteria, its not showing up, its only showing "No Rooms available".
    Any ideas, your help is really appreciated.
    THanks
    VIjay

    Hi Jürgen,
    see the following links:
    KM-COL Upgrade SP10 to SP13 - No rooms in the directory
    More than ten rooms in Room Directory?
    as well as the links to help.sap.com provided there.
    Hope it helps
    Detlev

Maybe you are looking for