• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

Converting a Vector to a String  RSS feed

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Im in some dire need of some basic help. Im having a problem trying to convert a vector to a string. I have a JComboBox which shows the data which is obtained from a database and placed into a combo box, and this works fine.
I want it so that when a select a value in a combobox, that value is then passed/placed into a jtextfield, and so need to convert a vector to a string (array possibly), im completely stuck on this.
Please help a poor student out.
 
Ranch Hand
Posts: 2120
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch Luke!
This is from the API for Vector:
public String toString()
Returns a string representation of this Vector, containing the String representation of each element.

This means that the method toString in Vector class has overriden the default implementation that inherits from Object.toString. Because toString is declared in Object all their subclasses inherit it. It was sensible to look up the API to see if Vector had overriden it.
I always have the API link bookmarked in a bar of Mozilla. It is absolutely compulsary.
[ March 06, 2004: Message edited by: Jose Botella ]
 
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
So u got the soultion how to convert the vector into string but i thought u dont need to convert vector into String for your requirement....
You can select the value directly from combobox just by the method
jCombobox.getSelectedObject return object convert it into string by toString method and if u want an index u get it by jComboBox.getSelectedIndex return and integer value..........
Vishal
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!