Ask Experts Questions for FREE Help!
  Advanced
Register  |  Log in  
   Ask    
 Answer  
  Help  

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

 
Question Tools Search this Question Display Modes
Question
 
 
#1  
Old Jul 4, 2006, 12:35 AM
guyshahar
New Member
guyshahar is offline
 
Join Date: Jan 2006
Posts: 14
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, 12:12 AM   #2  
LTheobald
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, 12:29 AM   #3  
guyshahar
New Member
guyshahar is offline
 
Join Date: Jan 2006
Posts: 14
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
 
     


Question Tools Search this Question
Search this Question:

Advanced Search
Display Modes

 
Similar Sponsors

Similar Questions
Question Asker Topic Answers Last Post
regripping the golf club at the top of the swing robert behnke Golf 2 Jul 1, 2008 12:01 PM
golf swing adcast Golf 2 Jan 30, 2006 01:39 PM
Help with 1930's swing:Kiss me sweet/simple offgrid Music 1 Dec 27, 2005 11:54 PM
Jules Pfeiffer-the tire swing LWhiteside Art 3 Feb 2, 2005 01:20 PM
Java - SWING not Working!!! aguilmet Internet & the Web 0 Aug 11, 2004 02:37 PM




Copyright ©2003 - 2007, Ask Me Help Desk.
All times are GMT -8. The time now is 01:49 PM.

Content Relevant URLs by vBSEO 3.0.0 RC6 © 2006, Crawlability, Inc.