Ask Experts Questions for FREE Help !
Ask
    guyshahar's Avatar
    guyshahar Posts: 21, Reputation: 2
    New Member
     
    #1

    Jul 4, 2006, 01:35 AM
    Java Swing Problem
    A JComboBox has constructors that can take a Vector or a ComboBoxModel.

    When I pass a DefaultComboBoxModel to it, and change the contents of the DefaultComboBoxModel, the drop-down list changes as expected. No problem.

    However, if I pass a Vector to it and change the contents of the Vector, the drop-down list goes blank. It is still there, because if I click on any point in the blank space, the most recent option is called and the list is then visible.

    I have tried calling validate() on the JComboBox, but it makes no difference.

    I want to experiment with generics, and cannot do so with DefaultComboBoxModel. Can anybody tell me a simple way to use Vectors in Swing without weird results??
    LTheobald's Avatar
    LTheobald Posts: 1,051, Reputation: 127
    Ultra Member
     
    #2

    Jul 5, 2006, 01:12 AM
    I missed this one yesterday. I'll try and recreate the problem myself some time today.

    In the meanwhile let me know what JDK you are using in case that makes a difference.
    guyshahar's Avatar
    guyshahar Posts: 21, Reputation: 2
    New Member
     
    #3

    Jul 5, 2006, 01:29 AM
    Thanks. It's the 5.0 JDK for Windows.

    Somebody proposed a solution to me that seems to work. They told me that having updated the Vector, I need to add the line:

    ComboBox.setModel(new DefaultComboBoxModel(vector));

    And this updates the drop-down list.

    Strange that without this line, the list updates eventually, but is initially blank...

Not your question? Ask your question View similar questions

 

Question Tools Search this Question
Search this Question:

Advanced Search

Add your answer here.


Check out some similar questions!

Help with 1930's swing:Kiss me sweet/simple [ 4 Answers ]

There is a lost song (at least I can't find it) that was pressed on a 78 that I used to listen to at a neighbors house in the 1950's, and it was old then! Then, my parents moved, and I've been looking for the song ever since. The melody followed a classical comosition, but the words were...

Regripping the golf club at the top of the swing [ 2 Answers ]

To whom it may concern, I am a 7 handicap and I have been having problems regriping the club at the top of my back swing. Is there any drills or things I can practice to stop this habit? Thanks Bob

Golf swing [ 2 Answers ]

Hi experts, I'm a lady golfer with a 15 handicap. I always make it a point to be aware of my right elbow on the take away. But what I'd like to know is how high up and how close to the body by right elbow should be on the backswing. Thanks for any information.

Jules Pfeiffer-the tire swing [ 3 Answers ]

I'm looking for a Jules Pfeiffer cartoon depicting the demise of an idea for a tire swing as it moved from what the customer wanted through various departments such as research, design, engineering, marketing until it went into production and came out looking nothing like the original concept. ...


View more questions Search