Repeated entries in JComboBox

The problem I encountered is that while JComboBox can display repeated items, it doesn't allow selecting them. Try selecting item #2 in the attached example. Any suggestions?
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import javax.swing.JComboBox;
import javax.swing.JFrame;
public class ComboTest extends JFrame
     private JComboBox m_name;
     public ComboTest()
          String[] values = {"item 0 is unique","items 1 and 2 are identical","items 1 and 2 are identical","item 3 is unique"};
          m_name = new JComboBox(values);
          m_name.addItemListener(new ItemListener()
                    public void itemStateChanged(ItemEvent e)
                         System.out.println("itemStateChanged, new index = "+m_name.getSelectedIndex()+" >>>"+e.paramString());
          m_name.addActionListener(new ActionListener()
                    public void actionPerformed(ActionEvent e)
                         System.out.println("actionPerformed, new index = "+m_name.getSelectedIndex()+" >>>"+e.paramString());
          m_name.setSelectedIndex(-1);
          m_name.setEditable(true);
          getContentPane().add(m_name);
          setSize(250,60);
     public static void main(String[] args)
          ComboTest mm = new ComboTest();
          mm.show();

I would agree with earlier posters who suggested that putting repeated entries into the JComboBox is probably not much help. It seems better to wrap People up in a class which contains some unique identifier, even if the toString() method can return duplicates.
You can get what you want, but you will have to write a custom ComboBoxModel, since DefaultComboBoxModel delegates storage to java.util.Vector, which returns the first index that matches when you use indexOf. See http://java.sun.com/j2se/1.3/docs/api/java/util/Vector.html#indexOf(java.lang.Object) for more details.
There are plenty of problems in Java. I don't think this is one of them.
-- Scott

Similar Messages

  • Calendar Sync Issue With repeating entry deletions Notes 8.5 to BB

    I have an issue where when synchronizing may calendar with Lotus Notes version 8.5, the Blackberry will delete repeating entries. Specifically, if I load the Blackberry with all my calendar entries from Notes and then in one entry in my Notes calendar a "single" occurance of a meeting gets canceled .. the next time I sync with the Blackberry it deletes "all" occurances of that meeting from the BB. The entries remain correct on Lotus Notes. The only way I can seem to fix that is to reset sync setting and reload the calendar to the BB all over again, and then this occurs again .... this happens with both V5 and V6 of the BB Desktop Software. Has anyone seen this and is there a fix ?

    I have an issue where when synchronizing may calendar with Lotus Notes version 8.5, the Blackberry will delete repeating entries. Specifically, if I load the Blackberry with all my calendar entries from Notes and then in one entry in my Notes calendar a "single" occurance of a meeting gets canceled .. the next time I sync with the Blackberry it deletes "all" occurances of that meeting from the BB. The entries remain correct on Lotus Notes. The only way I can seem to fix that is to reset sync setting and reload the calendar to the BB all over again, and then this occurs again .... this happens with both V5 and V6 of the BB Desktop Software. Has anyone seen this and is there a fix ?

  • IOS7:  "all-day, repeating" entry from all-day to a specific time.

    Since upgrading to ios7 (iPhone 5, Verizon) when using the calendar I can't switch an "all-day, repeating" entry from all-day to a specific time. There's no "all-day" toggle switch.  Does anyone know how to correct this?  My friend has the 5s & AT&T and she doesn't have this problem.  Hers shows a toggle switch!

    I haven't completely discounted it but it seems like I would need to back up to files, then restore from files. I don't want to do that. I want a full file system level SAN snapshot that I can just drop into place. The does work when the production base is shut down. However, considering that I do have archive logs, shouldn't it be possible to use them to recover to a specific scene without having to do an RMAN backup at all? It seems that doing an RMAN backup/recovery would just make this whole process a lot longer since the DB is 160 gigs in size (not huge, but the dump would take more time than I would like). With a SAN snapshot, if I can get this to work, I'm looking at about a 15-20 minute period of time to move the production DB over to test.
    Since you are suggesting that RMAN may be a better approach I'll provide more details about what I'm trying to do. Essentially this is like trying to recover a DB from a server that had its power plug pulled. I was hoping that Oracle's automatic recovery would do the same thing it would do in that instance. But obviously that doesn't work. What I want to do is bring over all the datafiles, redo logs, and archive logs using the SAN snapshot. Then if possible use some aspect of Oracle (RMAN if it can do it) to mount the database, then recover to a specific time or SCN if using RMAN. However, when I tried using RMAN to do it, I got an error saying that it couldn't restore the data file because it already existed. Since I don't want to start from scratch and have RMAN rebuild files that I've already taken snapshots of (needless copying of data), I gave up on the RMAN approach. But, if you know of a way to use RMAN so that it can recover to a specific incarnation without needing to runm a backup first, I am completely open to trying it.

  • Repeated entries in VAPMA-sales index table-order item

    Hi,
    I want to know in which scenario SAP system create repeated entries in VAPMA-sales index table for same material and same order.as in my scenario system had created a repeated entries in VAPMA for same material in sales order.so it looks like duplicate entries except there is difference in some of the primary keys.
    Thanks
    Manish Gupta

    Uhm... VAPMA is just an index table of VBAP/VBAK entries, so when you have different key fields that's when you'll see the "repeated" entries. When the key fields are different it's not a duplicate.

  • Calender repeat entries appering again post deletion

    calender repeat entries appering again post deletion

    Hi - and thanks for your tip. Unfortunately it didn't bring about a restoring of the data lost during my last sync. I tried to import, from my old username, into the new username a file in the Bakcup file called Calender locationsDB-PDat.PDB, but with no more success.
    The Sunday backup simply erased all individual entries in the calender from both handheld and Palm Desktop, keeping annual reminders and strings of repeated events like 'holiday' or the like, as well as address book and memos.
    At least the new entries since the traumatic backup on Sunday went in on the Palm Desktop on to-day's sync and stay therewith all the birthdays etc, but with no other events - on my old username! I tried to import the file datebook.002.dat which is 1259 kB, but it does not appear on the box when I use the "import" procedure. So I'll just live without past history on my Palm. Sad but apparently a fact.
    Again thanks - I've learnt a lot on the inner life of Palm on my PC!
    Torsten
    Post relates to: Tungsten E2

  • Only receiving repeat entries in iCal on iPhone 3GS v5.1.1 since iMac went down for service

    Yesterday I took my iMac in for service.  Today I was checkingl entries in iCal in my iPhone 3GS v5.1.1 and all entries were missing except those that were Repeat entries.  I tried to go to iCloud to check iCal but iCloud didn't recognize my account and password and said I had to creat a new account.
    What is up?

    I had this same exact issue while traveling in Italy and France (I returned yesterday 17-October).
    Before leaving, I verified by phone w/At&T that I had all necessary features to use my phone overseas. They said yes I did have all necessary features to use my phone overseas. They did offer me their AT&T World Traveler plan for $5.99/month but I declined since I would not use this feature enough to justify the monthly cost. They said my phone would still work overseas, but my per minute usage rate would be slightly higher. ...HOWEVER, I could not connect with any of the available networks while overseas (same results/messages as you).
    I just spoke w/At&T again. Now they say I did not have the necessary feature to use my phone overseas. This is what I found out:
    1. You can sign up online for the World Traveler $5.99/month plan. This will allow you to use your phone overseas.
    2. If you do not want the $5.99/month plan, you need to have the Expanded International Roaming feature activated on your phone. If it is activated, you will see it on your online account under "International Features". Be aware, the rates will be higher for all services (I believe they told to make sure "Data Roaming" is turned off, otherwise I will be charged $20.00/minute for internet access")
    3. If you have had your phone less than 90 days, and you want to activate Expanded International Roaming, you must call AT&T and ask to speak with International customer service. According to my recent phone call with AT&T, this is the only department that can activate the services (@ less than 90 days).
    I'm still not confident this issue is resolved, but I will find out next time I travel outside the United States.

  • Add repeating entry to collection

    Hi
    How can I add repeating entry to collection. For example by pressing button it add entry to collection with date column on 1st of month and with text "example" in column Text for 5 years so the collection will looks like this
    1/1/2014   example
    2/1/2014   example
    3/1/2014   example
    12/1/2018  example

    We do not currently support the list comprehension sort of construct that you describe. However, you can use the timer control to simulate iteration. Hopefully the following example will help you get started.
    Add a timer control to your canvas. Change its properties as follows:
    TimerEnd: UpdateContext({TStart:100});UpdateContext({TStart:0});UpdateContext({counter:counter+1})
    End: 2
    Start: TStart
    Text: "Timer: " & counter
    Now hit F5 to go to preview mode. Click the timer control. You will see it steadily increasing--you can speed up by setting Interval to 0.1 or something like that.
    What is happening is that the timer is going from 0 to 2. When it hits 2, the TimerEnd rule resets TStart to 100 and then to 0--the variable's value needs to change for data to flow. This will cause the timer to continue in a loop. We also increment
    counter--this value is displayed on the timer itself because of the Text rule above. What you now have is essentially a while loop and you can add Collect statements to the end of the TimerEnd rule to collect values of the counter.
    You can also set termination condition:
    TimerEnd: If(counter < 5, UpdateContext({TStart:100});UpdateContext({TStart:0});UpdateContext({counter:counter+1}), false)
    I hope that gets you started :-)

  • How to repeat entries on calendar (ie. Second Wednesday of each month

    How would I enter repeating entries in calendar (ie. Second Wednesday of each month).

    Does anyone from Apple read these requests.  I need and want to repeat events like every 1st and 3rd Thursday and every 2nd and 4th Tuesday.  Too bad for Apple for not listening to these messages that have been going on for several years now.  I'm a brand new iPhone user and feel it would benefit Apple to correct this lacking feature.

  • To count the repeated entries in a XML document.

    HOW TO COUNT THE REPEATED  NUMBER OF ENTRIES IN A XML DOCUMENT USING THE SAP REPORT PROGRAM?
      <?xml version="1.0" encoding="utf-16" ?>
    - <ROOT>
    - <SYSTEMDETAILS>
    - <item>
      <SYSDETAILSNAME>CODE</SYSDETAILSNAME>
      <SYSDETAILS>00</SYSDETAILS>
      </item>
    - <item>
      <SYSDETAILSNAME>LICENSE</SYSDETAILSNAME>
      <SYSDETAILS>INITIAL</SYSDETAILS>
      </item>
    - <item>
      <SYSDETAILSNAME>BASIS RELEASE</SYSDETAILSNAME>
      <SYSDETAILS>700</SYSDETAILS>
      </item>
    - <item>
      <SYSDETAILSNAME>SYSTEM NAME</SYSDETAILSNAME>
      <SYSDETAILS>IS3</SYSDETAILS>
      </item>
    - <item>
      <SYSDETAILSNAME>CLIENT</SYSDETAILSNAME>
      <SYSDETAILS>800</SYSDETAILS>
      </item>
    - <item>
      <SYSDETAILSNAME>LOCLANG</SYSDETAILSNAME>
      <SYSDETAILS>English</SYSDETAILS>
      </item>
      </SYSTEMDETAILS>
    - <ACH>
    - <item>
      <NAME>HLA0009999</NAME>
      <TLEVEL>01</TLEVEL>
      <TEXT>SAP</TEXT>
      <TEXT4>Application Components</TEXT4>
      <TEXTLOC>Application Components</TEXTLOC>
      </item>
    <item>
      <NAME>ABA0000311</NAME>
      <TLEVEL>02</TLEVEL>
      <TEXT>AP</TEXT>
      <TEXT4>Application Platform</TEXT4>
      <TEXTLOC>Application Platform</TEXTLOC>
      </item>
    - <item>
      <NAME>KPE0000001</NAME>
      <TLEVEL>03</TLEVEL>
      <TEXT>AP-PPE</TEXT>
      <TEXT4>Integrated Product and Process Engineering</TEXT4>
      <TEXTLOC>Integrated Product and Process Engineering</TEXTLOC>
      </item>
    SAY THE  BOLD PART SHOWS 1 USER ,SO HOW MANY TIMES THE SAME USER APPEARS IN THE DOCUMENT.
    HOW CAN I FIND THAT?

    If the same content of file already thr in the Internal table as 1 STRING/LINE then you can loop the internal table count the entries which one you want like
    Kanagaraja L

  • CS4 index code for subentry repeats entry term

    I'm indexing a book and for each subentry I'm getting a repeat of the entry string concatenated with the subentry value. For example:
    Agencies 357
    Agenciesconsumer rights 359
    Agenciesinterview questions 358
    Agenciesregistry or staffing 357
    Problem appears to be in Word Import where InDesign creates index codes with erroneous content. I've tested with with RTF, Word 97-2003 and Word 2007 format and the results are the same.
    Running CS4 on Windows Vista. Index markers were imported from Word 2007 using Word 97-2003 format. Index worked correctly in Word.
    I've got a 500 page book with complex layout that is ready to go once I get the index fixed!
    Suggestions welcome, thank you.

    Yes, I'm using 6.0.4. The bug is still here.
    I think the easiest work around may be to:
    place the original Word document (with its imbedded index markers) into CS3 (if you have it!)
    generate the index and save the CS3 file
    open the CS3 ID file in CS4
    index generation now works fine
    This should, of course, be done before any formatting begins.
    Exporting the document from CS4 to INX, then loading into CS3 doesn't work.
    It seems the problem is with CS4's inability to properly deal with the second level index markings of Word.

  • Duplicate entry in JComboBox

    Hi:
    I need to find the index of the selected item in a JComboBox which has duplicte entries. The getSelectedIndex() returns the index of the 1st entry in the list that matches. Any suggestion?
    Thanks.

    you might be able to wrap the items in an object which contains the index
    something like this
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    class Testing extends JFrame
      String[] data = {"Hello","World","Hello","World","Hello","World"};
      JComboBox cbo = new JComboBox();
      public Testing()
        setLocation(400,300);
        setDefaultCloseOperation(EXIT_ON_CLOSE);
        JPanel jp = new JPanel();
        for(int x = 0; x < data.length; x++) cbo.addItem(new ComboItem(data[x],x));
        jp.add(cbo);
        getContentPane().add(jp);
        pack();
        cbo.addActionListener(new ActionListener(){
          public void actionPerformed(ActionEvent ae){
              JOptionPane.showMessageDialog(null,"Selected Index = "+((ComboItem)cbo.getSelectedItem()).index);}});
      public static void main(String args[]){new Testing().setVisible(true);}
    class ComboItem
      String data;
      int index;
      public ComboItem(String d, int i){data = d; index = i;}
      public String toString(){return data;}
    }

  • Collect repeated entries in internal table

    Hi,
    I have an internal table with a field logk and prof..i have multiple entries for logk. i want to collect all multiple entries for a particular value of logk to put into error log.can u help me out.
    Thanks ,
    Anand.

    if prof is a numeric tye field you can do like this
    sort itab.
    loop at itab.
    collect itab into itab1.
    endloop.
    Here Itab1 must be of same structure as itab
    Regards,
    Ravi

  • How to remove repeated entries of Group level details?

    My Crystal reports has three groups and layout is:
    GH1
    GH2
    GH3
    Details
    GF3
    GF2
    GF1
    I'm listing details under GF3. Is there a way I can control repeated listing of GH1 and GH2 data in different lines?
    e.g., my data column is: (zone, Bin, item name) and Zone is first level Group data, second level group data is at Bin level and third group is at item level.
    some record are like:
    (AZone, A1Bin, item1), (AZone, A1Bin, item2), (AZone, A2Bin, item3), by listing the details (zone, bin, Item) at GF3, my data is printed like this:
    AZone     A1Bin     item1
    AZone     A1Bin     item2
    AZone     A2Bin     item2.
    I want to print Zone and Bin level details only when these changes like:
    AZone      A1Bin     item1
              item2
         A2Bin     item3
    Any help on how can I achieve this? I don't want to pring Zone or Bin level details in seperate rows, these should appear together as listed above, also for fulfiling other requirements, I need to out data in GF3 section only.

    on that Common Tab it also has "Suppress if Duplicated",
    however, you would be far better off to work this out by tweaking
    the query (if you can) with joins and filters.
    Hope this helps,
    The Panda

  • Mysterious repeated entries in System Log

    I just noticed this tonight, as DejaVu was performing the daily backup, but have never seen it before. In the System Log, beginning at 2:15 this afternoon and every minute thereafter is the entry:
    +May 11 20:49:22 mike-harrisons-power-mac-g4 launchd: org.postfix.master: 9 more failures without living at least 60 seconds will cause job removal+
    I've noticed nothing out of the ordinary; I probably would never have known had I not had Console displaying the System Log. But what could this mean? I don't like seeing the word 'failure' anywhere in anything having to do with the System.
    Thanks.

    Thanks, guys...
    It sure does look like something related to mail delivery. But when I looked at the System Log again this morning, that entry no longer appears. It's one of those strange mysteries... like finding yourself in bumper-to-bumper traffic on a freeway and then, after what seems like an eternity, things start moving again but you never find out what the cause of the tie-up was.
    Thanks again.

  • Repeating entries in log.smbd

    I've recently started seeing this message repeating every few seconds in log.smbd (Windows File Service):
    [2009/08/11 17:28:17, 1] pdbods.c:odssamgetgrgid(2870)
    odssam_getgrgid: gid [99]
    Coincidentally, I'm now having problems with an application that copies files from the server, although doing it via the Explorer appears unaffected.
    Does anyone know what this means? Google is strangely not forthcoming on this message.
    Thanks.

    This is a 5.3.1 specific bug (it has just been released today), not related to the Time Capsule.
    It doesn't appear to stop the AirDisk working. But I have not idea why would the AirPort Utility have to gain access to the Mac?
    @Seanessy: If you are paranoid, maybe you should to hide your IP address in that message.

Maybe you are looking for

  • Itunes 12.1.1.4 not run cd rom on windows xp sp3. have removed all cd burning software

    itunes 12.1.1.4 not run cd rom on windows xp sp3. have removed all cd burning software.

  • Splitting the items to be posted to movt type 501/502

    Hi Suppose if there are 1000 records in the flat file, first system will sort the line items material wise. For E.g., with material A -300 records, material B-300 records, material C -400 records. It will create one material document each for materia

  • Middle Click in AS3

    Hi !!! I'm looking for the way to detect the middle click with AS3. I know there is a MouseEvent.MIDDLE_CLICK, but it's only for AIR: http://livedocs.adobe.com/flash/9.0/...l#MIDDLE_CLICK Why Flash didn't put that function for Flash Player too??? How

  • Error in show space script.

    Hi Gurus, When ever I the below query as SYS user it is retrieving the rows without any issues. select SEGMENT_NAME, FREE_BLOCKS,TOTAL_BLOCKS,UNUSED_BLOCKS from table( show_space_for( '%',user,'%' ) ) but If change the user name(below is changed scri

  • Non responsive firefox & stops in mid sentance in messanger or e-mail. Hour glass shows!

    Foxfire VERY SLOW RESPONSE, TO OPEN FIREFOX. ALSO IT WILL SAY fIREFOX NON-RESPONSIVE & A HOUR GLASS SIGN SHOWS UP. i WILL BE WRITING IN CHAT OR AN E-MAIL 7 IT STOPS TYPING, AN HOUR GLASS SHOWS UP & IT WILL SAY NON-RESPONSIVE. i'M AM GETTING UPSET WIT