Monika
May 12th, 2000, 06:34 AM
I have a vector class object in which I have stoted Strings.
Can I convert it into MenuItem objects?(some casting)
If I can ,then how?
Can I convert it into MenuItem objects?(some casting)
If I can ,then how?
|
Click to See Complete Forum and Search --> : Vector Class Monika May 12th, 2000, 06:34 AM I have a vector class object in which I have stoted Strings. Can I convert it into MenuItem objects?(some casting) If I can ,then how? dogbear May 12th, 2000, 09:56 AM Monika, The following code snippet should do the trick://Create your vector object and fill it with Strings Vector myVector = new Vector(1); myVector.addElement("New"); myVector.addElement("Open"); myVector.addElement("Save"); myVector.addElement("Save As..."); //create your Menu that will hold your MenuItems Menu fileMenu = new Menu("File"); //now add MenuItems to the Menu, giving the //Strings from the Vector as the label... for ( int index = 0 ; index < myVector.size() ; index++ ) fileMenu.add(new MenuItem((String)myVector.elementAt(index))); And that's it! Hope this helps. Regards, dogBear codeguru.com
Copyright Internet.com Inc., All Rights Reserved. |