I am looking for code that will add favorites / MRU type behavior to a JComboBox.
I could code this myself, but it sure seems like someone else has probably already done it.
I found the following (which looks exactly like what I want, but the source code is nowhere near complete): http://java.sys-con.com/node/36658
Any suggestions? I need to keep this relatively light, so I’d prefer to not use a component that’s part of a monolithic widget library, and open source is preferred.
Consider extending
DefaultComboBoxModel: overrideaddElement()andinsertElementAt()to insert at zero and remove the last element.Addendum: Here’s an example; per SO, the license is cc-wiki. I’d use
Preferencesto persist the entries.