Point Object in a Vector

Is there a way to obtain the x (or y) coordinate of a point that has been placed in a vector?
Vector vecArr = new Vector();
vecArr.addElement(new Point(e.getX(), e.getY())); I've tried getting it the way I've done it before in a standard array (array[0].x etc..), but it doesn't recognise the x or y.

int x = ((Point )(vecArr.elementAt(your_index))).x;
// but if you have used an array of Objects instead of point
// the solution is the same
int x0 = ((Point )yourArrayOfObjects[0]).x; but if you use Tigrr, you can define a Vector of Points, too.

Similar Messages

  • Putting Resultset objects in an Vector

    Can anybody help me, I have to put all my results from the ResultSet in a Vector.
    But I don't know how.
    Thanx in advance.

    for a vector of vector ....
    public static Vector prepareData(ResultSet rs)
         Object lValue=null;
         Vector returnedVector=new Vector();
         try
              Enumeration lEnum=null;
              rs.beforeFirst();
              while (!rs.isLast())
                   lEnum=this.elements();
                   Vector lLine=new Vector();
                   int i=0;
                   rs.next();
                   while (lEnum.hasMoreElements())
                        lValue=rs.getObject(i);
                        lLine.add(lValue);
                        i++;
                   returnedVector.add(lLine);
         catch (SQLException e)
              e.printStackTrace();
         return returnedVector;          

  • How do I  print out the attributes of objects from a  Vector?  Help !

    Dear Java People,
    I have created a video store with a video class.I created a vector to hold the videos and put 3 objects in the vector.
    How do I print out the attributes of each object in the vector ?
    Below is the driver and Video class
    Thank you in advance
    Norman
    import java.util.*;
    public class TryVideo
    public static void main(String[] args)
    Vector videoVector = new Vector();
    Video storeVideo1 = new Video(1,"Soap Opera", 20);
    Video storeVideo2 = new Video(2,"Action Packed Movie",25);
    Video storeVideo3 = new Video(3,"Good Drama", 10);
    videoVector.add(storeVideo1);
    videoVector.add(storeVideo2);
    videoVector.add(storeVideo3);
    Iterator i = videoVector.interator();
    while(i.hasNext())
    System.out.println(getVideoName() + getVideoID() + getVideoQuantity());
    import java.util.*;
    public class Video
    public final static int RENT_PRICE = 3;
    public final static int PURCHASE_PRICE = 20;
    private int videoID;
    private String videoName;
    private int videoQuantity;
    public Video(int videoID, String videoName, int videoQuantity)
    this.videoID = videoID;
    this.videoName = videoName;
    this.videoQuantity = videoQuantity;
    public int getVideoID()
    return videoID;
    public String getVideoName()
    return videoName;
    public int getVideoQuantity()
    return videoQuantity;
    }

    Dear Bri81,
    Thank you for your reply.
    I tried the coding as you suggested
    while(i.hasNext())
    System.out.println( i.next() );
    but the error message reads:
    "CD.java": Error #: 354 : incompatible types; found: void, required: java.lang.String at line 35
    Your help is appreciated
    Norman
    import java.util.*;
    public class TryCD
       public static void main(String[] args)
         Vector cdVector = new Vector();
         CD cd_1 = new CD("Heavy Rapper", "Joe", true);
         CD cd_2 = new CD("Country Music", "Sam", true);
         CD cd_3 = new CD("Punk Music", "Mary", true);
         cdVector.add(cd_1);
         cdVector.add(cd_2);
         cdVector.add(cd_3);
         Iterator i = cdVector.iterator();
         while(i.hasNext())
           System.out.println( i.next() );
    public class CD
       private String item;
       private boolean borrowed = false;
       private String borrower = "";
       private int totalNumberOfItems;
       private int totalNumberOfItemsBorrowed;
       public CD(String item,String borrower, boolean borrowed)
         this.item = item;
         this.borrower = borrower;
         this.borrowed = borrowed;
       public String getItem()
         return item;
       public String getBorrower()
         return borrower;
       public boolean getBorrowed()
         return borrowed;
       public String toString()
          return System.out.println( getItem() + getBorrower());

  • Vector, calling a method of an object in a Vector

    hi and sorry for my poor english.
    problem:
    i have a Vector:
    Vector objects = new Vector();i put some Objects in this Vector:
    objects.addElement(new testObject());in the class testObejct() i've defined some methods like:
    public method1() {
        System.out.println("bla");
    }how can i call that methods now by my Vector?
    this doesn work :(
    objects.lastElement().method1();thanx :)

    The vector method lastElement() returns an Object type so you need to cast the Object retrieved to the correct type before you can call one of it's methods.
    Try something like
    testObject to = (testObject)objects.lastElement();
    to.method1();you can use instanceof to test if a class is a member of a particular type

  • I created a vector and added objects, but the vector is empty

    I created an object called a facility, it accepts 2 strings in the creator but stores the data as a string and a float. as you can see from the code below, i have tried to create a vector object to contain facilitys and named it entries. when i add objects to this vector, the vectors size does not change, and i cannot access elements of it via their index. but when i print the vector out i can see the elements? what is going on here. i am very confused. ps, if it helps i havent worked with vectors much before.
    FacilitysTest.java
    import java.util.*;
    public class FacilitysTest {
         public static void main (String [] args) {
         Facilitys entries = new Facilitys();
         entries.add("Stage","3.56");
         entries.add("kitchen","5.00");
         entries.add("heating","2");
    //     System.out.println(entries.firstElement() );
         System.out.println("printing out entries");
         System.out.println(entries);
         System.out.println();
         System.out.println("There are "+entries.size()+" entries");
         System.out.println();
         System.out.println("modifying entry 2");
         entries.setElementAt(new Facility("lighting","1.34"), 2);
         System.out.println(entries);
         System.out.println();
         System.out.println("deleting entry 1");
         entries.remove(1);
         System.out.println(entries);
    }the following is what happens when i run this code.
    the number (0,1,2) is taken from a unique number assigned to the facility and is not anything to do with the facilitys position in the vector.
    printing out entries
    Facility number: 0, Name: Stage , Cost/Hour: 3.56
    Facility number: 1, Name: kitchen , Cost/Hour: 5.0
    Facility number: 2, Name: heating , Cost/Hour: 2.0
    There are 0 entries
    modifying entry 2
    Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 2 >= 0
    at java.util.Vector.setElementAt(Vector.java:489)
    at FacilitysTest.main(FacilitysTest.java:17)
    Press any key to continue . . .
    Facilitys.java
    import java.util.*;
    public class Facilitys extends Vector {
         private Vector entries;
         public Facilitys( ) {
                 entries = new Vector();
        public void add( String name, String price ) {
             entries.add((new Facility( name, price) ));
        public Facility get(int index) {
              return ((Facility)entries.get(index));
         public float total() {
              float total = 0;
              for (int i = 0; i<entries.size();i++) {
                   total = total + ( (Facility)entries.get(i) ).getPricePerHour();
              return total;
        public String toString( ) {
            StringBuffer temp = new StringBuffer();
            for (int i = 0; i < entries.size(); ++i) {
                temp.append( entries.get(i).toString() + "\n" );
            return temp.toString();
    }

    are you reffering to where i have public class
    Facilitys extends Vector {
         private Vector entries;
         public Facilitys( ) {
                 entries = new Vector();
    That's correct. That's your problem.
    i added the extends Vector, because without it i got
    the following errors
    C:\Documents and Settings\george\My
    Documents\University\JavaCode\CM0112\FacilitysTest.jav
    a:14: cannot find symbol
    symbol : method size()
    location: class Facilitys
    System.out.println("There are "+entries.size()+"
    " entries");That's because you haven't implemented a size method in your class.
    ^
    C:\Documents and Settings\george\My
    Documents\University\JavaCode\CM0112\FacilitysTest.jav
    a:17: cannot find symbol
    symbol : method setElementAt(Facility,int)
    location: class Facilitys
    entries.setElementAt(new
    w Facility("lighting","1.34"), 2);That's because you haven't implemented setElementAt in your class.
    C:\Documents and Settings\george\My
    Documents\University\JavaCode\CM0112\FacilitysTest.jav
    a:21: cannot find symbol
    symbol : method remove(int)
    location: class Facilitys
         entries.remove(1);
    ^That's because you haven't implemented remove in your class.
    /Kaj

  • How can I store a File object into a Vector and get it back

    hi there
    I need to store a number of File object into a Vector first, and later on I need to get each File object out and work with it.
    Vector mylist;
    File[] myfile;
    ....get a list of files from using File Chooser
    mylist = new Vetor();
    for (i=0;i<myfile.length;i++){
    mylist.add(myfile);
    ..how do I get them back? i try to do this way
    for (i=0;i<mylist.size(); i++)
    File tempfile = mylist.get(i);
    ..work with tempfile. but I got java.lang.object error: imcompatible types. what can I do?

    Vector mylist;
    File[] myfile;
    ....get a list of files from using File Chooser
    mylist = new Vetor();
    for (i=0;i<myfile.length;i++){
    mylist.add(myfile);
    ok try this: i don't reall understand what your trying to do though...
    File[] files;
    // get files
    Vector fileList = new Vector();
    for (int i = 0; i < files.length; i++)
      fileList.add(files);
    // to get them out.
    for (int i = 0; i < fileList.size(); i++)
    ((File)fileList.elementAt(i)).toString();
    // or
    // to get them out.
    for (int i = 0; i < fileList.size(); i++)
    File temp = (File)fileList.elementAt(i);
    System.out.println(temp.toString);

  • How can I get an object from a vector, modify it and store it back ?

    Hello all,
    I have created the clase "node", this class has a "name" property and and "counter" property, and the associated method to set the name and make the couter increase value.
    In a different class I have a vector, and I add "node" objects to this vector.
    Once I've added a few objects "nodes" I need to get one, modify the value and the store it back in. Better if it is in the same position. ..
    Thanks, alot guys. I could not copy an paste the code because I have a whole bunch of things mixed in the same code. I'd not be understanble.
    Thanks again !!

    Never mind, thanks anyway ..

  • Why can't I add an Object[] to a Vector ? super Object[] ?

    I don't understand why javac rejects these two statements:
        Vector<? super Object[]> v= new Vector<Object[]>();
        v.add(new Object[0]);cannot find symbol
    symbol : method add(java.lang.Object[])
    location: class java.util.Vector<capture of ? super java.lang.Object[]>
    v.add(new Object[0]);
    ^
    The type of v can only be one of these 4:
    Vector<Object[]>, Vector<Object>, Vector<Serializable>, Vector<Cloneable>.
    Therefore, I should always be allowed to add an Object[] to it, right?
    The following example is very similar, but this one is accepted by javac.
        Vector<? super Number> v= new Vector<Number>();
        v.add(42);I didn't find a relevant difference to the first example, nor something in JLS3 that would forbid it. Is this a javac bug?

    There is a difference between legal and practical. Practical is a matter of opinion. I thought I should try the combinations to see which make sense.
    I don't find it intuative that list.add(list.get(0)) should fail to compile.
    While the definitions have a logic of their own, some are very hard to put it into english exactly what they really mean. This means finding a practical purpose for them even harder.
    For example List<? super Object>
    add(x) is legal for non-arrays
    method(list) is illegal for method(List<Object>) but is legal for method(List<? super Object[]>)
    public class A {
        public static void foo(List<? super Object[]> l) {    }
        public static void foo2(List<Object[]> l) {    }
        public static void foo3(List<? extends Object[]> l) {    }
        public static void bar(List<? super Object> l) {    }
        public static void bar2(List<Object> l) {    }
        public static void bar3(List<? extends Object> l) {    }
        public static void bar4(List<?> l) {    }
        public static void main(String[] args) {
            {   // can be { Object, Object[] }
                List<? super Object[]> l = new ArrayList<Object[]>();
                l.add(l.get(0));  // illegal
                l.add((Object) null);  // illegal
                l.add((Integer) null);  // illegal
                l.add((Object []) null); // illegal
                l.add((Integer []) null); // illegal
                l.add((Integer [][]) null); // illegal
                foo(l); // List<? super Object[]> - legal
                foo2(l); // List<Object[]> - illegal
                foo3(l); // List<? extends Object[]> - illegal
                bar(l); // List<? super Object> - illegal
                bar2(l); // List<Object> - illegal
                bar3(l); // List<? extends Object> - legal
                bar4(l); // List<?> - legal
            {   // can be Object[] or (? extends Object)[]
                List<Object[]> l = new ArrayList<Object[]>();
                l.add(l.get(0));  // legal
                l.add((Object) null);  // illegal
                l.add((Integer) null);  // illegal
                l.add((Object []) null); // legal
                l.add((Integer []) null); // legal
                l.add((Integer [][]) null); // legal
                foo(l); // List<? super Object[]> - legal
                foo2(l); // List<Object[]> - legal
                foo3(l); // List<? extends Object[]> - legal
                bar(l); // List<? super Object> - illegal
                bar2(l); // List<Object> - illegal
                bar3(l); // List<? extends Object> - legal
                bar4(l); // List<?> - legal
            {   // Only allows wildcards, Object is illegal.
                List<? extends Object[]> l = new ArrayList<Object[]>();
                l.add(l.get(0));  // illegal
                l.add((Object) null);  // illegal
                l.add((Integer) null);  // illegal
                l.add((Object []) null); // illegal
                l.add((Integer []) null); // illegal
                l.add((Integer [][]) null); // illegal
                foo(l); // List<? super Object[]> - illegal
                foo2(l); // List<Object[]> - illegal
                foo3(l); // List<? extends Object[]> - legal
                bar(l); // List<? super Object> - illegal
                bar2(l); // List<Object> - illegal
                bar3(l); // List<? extends Object> - legal
                bar4(l); // List<?> - legal
            {   // can add non-arrays but can only match ? super Object, ? super Object[], or ? extends Object, but not Object 
                List<? super Object> l = new ArrayList<Object>();
                l.add(l.get(0));  // legal
                l.add((Object) null);  // legal
                l.add((Integer) null);  // legal
                l.add((Object []) null); // illegal
                l.add((Integer []) null); // illegal
                l.add((Integer [][]) null); // illegal
                foo(l); // legal
                foo2(l); // illegal
                foo3(l); // illegal
                bar(l); // legal
                bar2(l); // illegal
                bar3(l); // legal
                bar4(l); // legal
            {   // can add array but cannot call a method which expects an array. 100% !
                List<Object> l = new ArrayList<Object>();
                l.get(0).toString();
                l.add(l.get(0));  // legal
                l.add((Object) null);  // legal
                l.add((Integer) null);  // legal
                l.add((Object []) null); // legal
                l.add((Integer []) null); // legal
                l.add((Integer [][]) null); // legal
                foo(l); // legal
                foo2(l); // illegal
                foo3(l); // illegal
                bar(l); // legal
                bar2(l); // legal
                bar3(l); // legal
                bar4(l); // legal
            {   // cannot add any type but can match ? or ? extends Object.
                List<? extends Object> l = new ArrayList<Object>();
                l.add(l.get(0));  // illegal
                l.add((Object) null);  // illegal
                l.add((Integer) null);  // illegal
                l.add((Object []) null); // illegal
                l.add((Integer []) null); // illegal
                l.add((Integer [][]) null); // illegal
                foo(l); // List<? super Object[]> - illegal
                foo2(l); // List<Object[]> - illegal
                foo3(l); // List<? extends Object[]> - illegal
                bar(l); // List<? super Object> - illegal
                bar2(l); // List<Object> - illegal
                bar3(l); // List<? extends Object> - legal
                bar4(l); // List<?> - legal
            {   // same as ? extends Object.
                List<?> l = new ArrayList<Object>();
                l.add(l.get(0));  // illegal
                l.add((Object) null);  // illegal
                l.add((Integer) null);  // illegal
                l.add((Object []) null); // illegal
                l.add((Integer []) null); // illegal
                l.add((Integer [][]) null); // illegal
                foo(l); // List<? super Object[]> - illegal
                foo2(l); // List<Object[]> - illegal
                foo3(l); // List<? extends Object[]> - illegal
                bar(l); // List<? super Object> - illegal
                bar2(l); // List<Object> - illegal
                bar3(l); // List<? extends Object> - legal
                bar4(l); // List<?> - legal
    }

  • Unexpected behavior when creating Objects in a Vector

    I have a situation where Objects in a Vector appear to be getting corrupted. The context is this: I obtain a ResultSet from a database, create a Vector of Strings for each row, and a Vector of these row vectors for the entire ResultSet. This is passed to a method where a POJO is created for each row. This method returns a Vector of these POJOs. In the Object constructor, a String array of initial values is created and also values are assigned to individual variables. Here is a snippet with the Object constructor
    public class RefAuthorItem {
         private final String refKey;
         private String authorKey, firstName, lastName, itemKey;
         private int authorPosition;
         private boolean isDeleted, isNew;
         // Keep a copy of the original values
         private final String[] oldValues;
          * The constructor for the data object item.
          * @param dataVals     a String array of the data values
          * @param isNewVal     boolean true if this is a new item, false if it is
          *                                              an existing item
         public RefAuthorItem(final String[] dataVals, final boolean isNewVal) {
              oldValues = dataVals;
              authorKey = dataVals[RefQueryBuilder.AUTH_NUM];
              firstName = dataVals[RefQueryBuilder.AUTH_FIRST_NAME];
              itemKey = dataVals[RefQueryBuilder.AUTH_PKEY];
              lastName = dataVals[RefQueryBuilder.AUTH_LAST_NAME];
              refKey = dataVals[RefQueryBuilder.AUTH_REF_FKEY];
              isNew = isNewVal;
              isDeleted = false;
              // the author position integer value is used to sort the display
              authorPosition =
                        Integer.parseInt(dataVals[RefQueryBuilder.AUTH_POS]);
         }It seems the oldValues[] values should be identical to the corresponding individual variable values. When the following code is used to create the objects, they are not.
              final boolean isNew = isNewVal;
              Vector<RefAuthorItem> returnSet = new Vector<RefAuthorItem>();
              final String queryString = QueryBuilder
                   .getRefQuery(keyString, tableName);
              Vector<Vector> dataSet = QueryDB.getResultSet(queryString);
              int columnTot = dataSet.firstElement().size();
                    String[] itemVals = new String[columnTot];
              for (Iterator iter = dataSet.iterator(); iter.hasNext();) {
                   Vector element = (Vector) iter.next();
                   for (int i = 0; i < columnTot; i++) {
                        itemVals[i] = (String) element.get(i);
                   RefAuthorItem item = new RefAuthorItem(itemVals, isNew);
                   returnSet.add(item);
              }What happens is this. I returned four rows from the database and the oldValues[] array for each of the four corresponding objects contains the data from the fourth row. However, when I retrieve the corresponding individual values (e.g., authorLastName) from the Object, it is correct. I checked the object values (oldValues versus individual values retrieved via getters) right after the object is created (the line: RefAuthorItem item = new RefAuthorItem(itemVals, isNew);) and get the correct results. Also, results are correct when the itemVals constructor is moved within the loop, as below
              int columnTot = dataSet.firstElement().size();
              for (Iterator iter = dataSet.iterator(); iter.hasNext();) {
                   Vector element = (Vector) iter.next();
                   String[] itemVals = new String[columnTot];
                   for (int i = 0; i < columnTot; i++) {
                        itemVals[i] = (String) element.get(i);
                   RefAuthorItem item = new RefAuthorItem(itemVals, isNew);
                   returnSet.add(item);
              } There is a problem here. Am I missing a subtle Java issue with instantiating the String array within the loop? Or is there a problem with Vectors? Thanks!

    Dear ejp,
    In the non-working code, I rewrite the itemVals[], create a new RefAuthorItem using the itemVals[] and repeat. I checked the RefAuthorItem immediately after it was created (with println()) and the oldValues and individual String values in the object are concordant. However, after the loop is completed (all RefAuthorItems are created and added to the Vector), the oldValues[] in the objects all have the values from the last row. The individual String variables in the object all have the correct value from the ResultSet row.

  • Measuring Point Object??

    Hi All
    Could anyone tell me where to maintain "Measuring Point Object" (TCode -"IK01") in SPRO?
    Regards.

    hi this is
    System table, maint. only by SAP, change = modification
    pl check with your technical team
    -ashok

  • Putting a Class Object into a Vector

    HI all
    I need to put a class object into another classes vector, then be able to read it and retrieve data.
    I can put the object into the vector but all i seem to be able to retrieve is data like Account@2343c2.
    Is this some sort of tag? How do i get to the data?
    thankz
    joey

    That's what you get when you print an object which does not have its own toString() method to do anything different - it picks up the Object class's toString method instead. For example:
    System.out.println(new Object());It sounds like you're doing something like this:
    Vector v = new Vector();
    v.add(new Account(42));If you were to do the following, you would see that sort of output:
    System.out.println(v.get(0));The appropriate way to do this would be something like the following:
       // Use a List reference instead of a Vector reference, and create
       // an ArrayList object in preference to a Vector object
       List list = new ArrayList();
       list.add(new Account(42));
       // Iterate through the list of accounts - use an
       // iterator because this prevents off-by-one errors
       // that arise with direct indexing.
       Iterator i = list.iterator();
       while(i.hasNext()) {
          // Cast the reference returned by the iterator from
          // Object to Account so that we can call account-specific
          // methods.
          Account current = (Account)i.next();
          // Call the method specific to the Account class (getBalance
          // is just an example that I made up).
          System.out.println(current.getBalance());
       }

  • Point Object of the Oracle Spatial

    Dear All,
    This is C. T. Lin. I got some problem about point object of the Oracle geometry!
    Describe:
    1.I use the GeoMedia Professional to export the points to Oracle, but the oracle do not insert the geometry data into the SDO_Point, the Geomedia put the point geometry into the Ordinate_Array.
    2. I also use the MapInfo Professional to export the points to oracle, then the geometry write in the SDO_Point!
    3. the problem is occur! the MapInfo look like support the Point object that define the coordinate in the SDO_Point ,only!
    So, Can some one tell me how to write the coordinate data from the Ordinate_array into SDO_point!

    First you should create a PL/SQL function that does this convertion. Here is two version of this function, one 2D and one 3D:
    CREATE OR REPLACE
    Function changePoint3D ( Geo Mdsys.Sdo_geometry )
    return Mdsys.Sdo_geometry AS
    declare
    Point mdsys.sdo_geometry ;
    begin
    Point := Mdsys.Sdo_geometry( 3001, 82344,
    Mdsys.Sdo_point_type( geo.sdo_ordinates(1), geo.sdo_ordinates(2), geo.sdo_ordinates(2) ),
                   NULL, NULL );
    return Point;
    end;
    Function changePoint2D ( Geo IN Mdsys.Sdo_geometry ) return Mdsys.Sdo_geometry AS
    Point mdsys.sdo_geometry ;
    begin
    Point := Mdsys.Sdo_geometry( 2001, 82344,
    Mdsys.Sdo_point_type( geo.sdo_ordinates(1), geo.sdo_ordinates(2), NULL ),
    NULL, NULL );
    return Point;
    end;
    When you have these functions defined it is very easy to do what you want with a simple update sentence , like this :
    update table_X set Geo_Column = changePoint3D( Geo_Column );
    Hope this helps you.
    Hans

  • [svn:fx-trunk] 12930: Optimize transformSize and transformBounds, reduce allocation of Point objects.

    Revision: 12930
    Revision: 12930
    Author:   [email protected]
    Date:     2009-12-14 16:23:58 -0800 (Mon, 14 Dec 2009)
    Log Message:
    Optimize transformSize and transformBounds, reduce allocation of Point objects.
    This change addresses a couple of FIXMEs I had put in the internal MatrixUtil class. The parameters were changed to numbers instead of points and I unrolled the matrix multiplication to significantly reduce the number of multiplications and additions. Both methods now return reference to the same internal static Point object to further reduce dynamic object allocation.
    QE notes: None
    Doc notes: None
    Bugs: None
    Reviewer: Deepa
    Tests run: checkintests, mustella tests/gumbo/layout
    Is noteworthy for integration: Yes
    Modified Paths:
        flex/sdk/trunk/development/eclipse/flex/sparkTest/src/layouts/WheelLayout.as
        flex/sdk/trunk/frameworks/projects/framework/src/mx/core/LayoutElementUIComponentUtils.as
        flex/sdk/trunk/frameworks/projects/framework/src/mx/core/UIComponent.as
        flex/sdk/trunk/frameworks/projects/framework/src/mx/graphics/BitmapFill.as
        flex/sdk/trunk/frameworks/projects/framework/src/mx/utils/MatrixUtil.as
        flex/sdk/trunk/frameworks/projects/spark/src/spark/components/supportClasses/ScrollerLayo ut.as
        flex/sdk/trunk/frameworks/projects/spark/src/spark/core/SpriteVisualElement.as
        flex/sdk/trunk/frameworks/projects/spark/src/spark/primitives/supportClasses/GraphicEleme nt.as

  • Change objects between 2 Vectors

    Voor mijn programma gebruik 2 Vectors (in klasse Schuif en Speelveld). In deze Vectors staan objecten van de klasse Steen (Een canvas, vierkantje met achtergrond).
    How do I change a object Stone in Vector Playfield to Vector Slider and
    substitute it for the first object Stone in Vector Slider and the substituted object Stone comes in for object Stone in Vector Playfield.
    Vector Playfield Vector Slider
    | | Steen | |
    | | <----------> | |
    | | | |
    Or can i use something better than Vectors, like ArrayList???
    I hope it's a little bit clear :S
    Thanks in advance

    Here is some of my code. Here i want to change 2 stones from place. This doesnot even work :-S
    When I call the method verPlaatsStenen(), my app is hanging... :-S
    How can i change 2 stones from place, just on the Playfield.
    import java.awt.*;
    import java.util.*;
    public class Speelveld extends Panel
         //private Steen[][] veld;
         //private Vector veldX = new Vector(5);
         private ArrayList veldX = new ArrayList(5);
         private Color[] kleuren = { Color.blue,
                                            Color.yellow,
                                            Color.pink,
                                            Color.cyan,
                                            Color.green,
                                            Color.magenta,
                                            Color.red,
                                            Color.black,
                                            Color.black };
         public Speelveld()
              setLayout(null);
              setBackground(Color.black);
              for (int a =0; a < 5; a++)
                   for (int b = 0; b < 9; b++)
                        //veldX.add(a, new Vector(9));
                        veldX.add(a, new ArrayList(9));
              for (int a =0; a < 5; a++)
                   for (int b = 0; b < 9; b++)
                        //((Vector)veldX.get(a)).add(b, new Steen(kleuren));
                        ((ArrayList)veldX.get(a)).add(b, new Steen(kleuren[b]));
              maakVeld();
         public void maakVeld()
              for (int x = 0; x < 5; x++)
                   for (int y = 0; y < 9; y++)
                        //Steen steen = (Steen)((Vector)veldX.get(x)).get(y);
                        Steen steen = (Steen)((ArrayList)veldX.get(x)).get(y);
                        //steen.setPositie((x * 45) + 10, (y * 45) + 10);
                        add(steen);
                        /*veld[x][y] = new Steen(kleuren[y]);
                        veld[x][y].setPositie((x * 45) + 10, (y * 45) + 10);
                        add(veld[x][y]);*/
         /*public Steen getSteen(int rij)
              return (Steen)((Vector)veldX.get(0)).remove(rij);
         public void setSteen(Steen steen, int rij)
              ((Vector)veldX.get(1)).add(rij,steen);
              maakVeld();
         public void verplaatsStenen()
              //Steen steen1, steen2;
              Steen[] temp = new Steen[2];
              temp[0] = (Steen)((Vector)veldX.get(3)).get(7);
              temp[1] = (Steen)((Vector)veldX.get(4)).get(2);
              ((Vector)veldX.get(3)).remove(7);
              ((Vector)veldX.get(4)).remove(2);
              ((Vector)veldX.get(4)).add(7, temp[1]);
              maakVeld();

  • Problem when adding java objects in a vector and passing thru web service

    Hi! I'm getting this error when I try to add a java object I created into a vector and passing it through a web service: java.lang.IllegalArgumentException: No Serializer found to serialize a 'testObj' using encoding style 'http://schemas.xmlsoap.org/soap/encoding/'
    This does not happen when I simply add strings or Integer objects into the vector. What am I missing?
    Thanks.

    just chek this
    http://forum.java.sun.com/thread.jspa?threadID=501189&messageID=2370914
    Edited by: garava on Jul 16, 2008 1:13 PM.
    It would be great if you could paste the wsdl part for that vector and just have a look for the complex typr cntent
    like for HashMap we have the following mapping
    <complexType name="HashMap">
      <sequence>
        <element name="item" minOccurs="0" maxOccurs="unbounded">
          <complexType>
            <sequence>
              <element name="key" type="anyType" />
              <element name="value" type="anyType" />
            </sequence>
          </complexType>
        </element>
      </sequence>
    </complexType>Since in Value it should again contain a mapping for the Object which you are trying to pass then only an appropriate serializer and deserilaizer would get generated. Hope this answers your query. For refernece
    http://www.theserverside.com/tt/articles/article.tss?l=Systinet-web-services-part-2
    [http://www.theserverside.com/tt/articles/article.tss?l=Systinet-web-services-part-2|For refernce tutorial]
    Thanks,
    Avadhoot Sawant.
    Edited by: garava on Jul 16, 2008 1:16 PM

Maybe you are looking for