• 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
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

Converting a Vector to a String

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
roses are red, violets are blue. Some poems rhyme and some are a tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic