• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

JComboBox (again!!)

 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm having a problem updating the ComboBox.
The ComboBox is filled using a Vector containing
a name, the contents of the Vector are cast to Strings, and displayed in the ComboBox.
However, a problem arises when an item is removed
from the Vector list, the ComboBox does not update
Is there an easy way to update this.
The Vector itself is defined in a seperate class.
Thanks for the help,
Kevin
 
"The Hood"
Posts: 8521
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
We really need to see the code that does not work.
 
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
maybe just call repaint,just a maybe try it.
 
Ranch Hand
Posts: 2823
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It sounds like you are just updating the Vector which you used to create the combo. That does not change the model within the combo. Either change the combo or create your own model and update it.
 
Kevin Magee
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here's some of my code.
The first method is called to edit an item in the vector
The second method is in another class (EditCard).
I'm getting the following error
A:\AlumniList.java:89: non-static method updateComboBox(int) cannot be referenced from a static context

 
Cindy Glass
"The Hood"
Posts: 8521
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The syntax ClassName.method() is for calling a static method. If you want to call a non-static method you need to use the syntax
objectName.method();
 
Kevin Magee
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks a lot for the help!!!

Kevin.
 
Kevin Magee
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I hate to be a pain. I just can't seem to get around this whole JComboBox thing (this is my first attempt to use swing).
My problem now is that I'm allowing the user
to select an item from the comboBox, edit, or delete the item. And using the index position from
the comboBox changing the Vector, and then changing the list in the comboBox.
I'm now getting a NullPointerException, when trying to pass the index position to a method which will update the comboBox.

I know the updateComboBox method isnt correct, I need to get the listName.toArray() (since I'm using a Vector in order to display a readable choice), but I just want to get it working, its starting to drive me crazy!!!
 
Do you pee on your compost? Does this tiny ad?
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic