Ask Experts Questions for FREE Help!
Ask    ||    Answer
 
Advanced  
 

Ask QuestionsprogressAnswer QuestionsprogressBuild ReputationprogressBecome an Expert
 
Free Answers in 3 Easy Steps

Register Now
3 Steps

At Ask Me Help Desk you can ask questions in any topic and have them answered for free by our experts. To ask questions or participate in answering them you must register for a free account. By registering you will be able to:
  • Get free answers from experts in any of our 300+ topics.
  • Accept money for answers that you provide.
  • Communicate privately with other members (PM).
  • See fewer ads.

Home > Computers & Technology > Programming > Compiled Languages > Java   »   Java Swing Problem

 
Thread Tools Search this Thread Display Modes
Question
 
 
#1  
Old Jul 4, 2006, 01:35 AM
guyshahar
New Member
guyshahar is offline
 
Join Date: Jan 2006
Posts: 21
guyshahar See this member's comment history on his/her Profile page.
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???

Reply With Quote
 
     

Answers
 
 
Old Jul 5, 2006, 01:12 AM   #2  
Ultra Member
LTheobald is offline
 
LTheobald's Avatar
 
Join Date: Feb 2004
Location: Cambridge, UK
Posts: 1,047
LTheobald See this member's comment history on his/her Profile page.LTheobald See this member's comment history on his/her Profile page.
Call LTheobald via Skype™ Send a message via MSN to LTheobald
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 incase that makes a difference.
  Reply With Quote
 
     
 
 
Old Jul 5, 2006, 01:29 AM   #3  
New Member
guyshahar is offline
 
Join Date: Jan 2006
Posts: 21
guyshahar See this member's comment history on his/her Profile page.
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......
  Reply With Quote
 
     

Your Answer
Email me when someone replies to my answer
Join Login





Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

 
Similar Sponsors


Thread Tools
Show Printable Version Show Printable Version
Email this Page Email this Page

Similar Threads
regripping the golf club at the top of the swing
(2 replies)
golf swing
(2 replies)
Help with 1930's swing:Kiss me sweet/simple
(1 replies)
Jules Pfeiffer-the tire swing
(3 replies)
Java - SWING not Working!!!
(0 replies)

Search this Thread

Advanced Search

Bookmarks

Sponsors



Copyright ©2003 - 2009, Ask Me Help Desk.
All times are GMT -8. The time now is 03:48 PM.