Moving array between classes

Hello there. Right, i have 3 classes with which i am having a bit of trouble with. The first class, "Drawing," creates an array called componentList. Then, in another class called "DrawingCanvas" i have an instance of "Drawing" created. In this second class i have two methods which need to use the array from the first class. These methods are called from a third class, "DrawingFrame."
My problem is that i do not know how to pass the array from "Drawing" into "DrawingCanvas" when i call a method from "DrawingFrame."
Any help is appreciated.

despite understanding your replys, i am still having trouble. i think it is because i am trying to put the array into an actionPerformed method. below is the method where i need to pass the array into:
   public JMenuItem createFileSaveItem() {
        JMenuItem item = new JMenuItem("Save Current Drawing"); // Item name
        class MenuItemListener implements ActionListener {
            public void actionPerformed(ActionEvent event) { // Event when item clicked
                      test.saveArray(componentList);              
        ActionListener listener = new MenuItemListener();
        item.addActionListener(listener);
        return item;
    }the "test.saveArray(componentList)" is showing as an error. (cannot find symbol componentList)
at the top of this class i have put:
DrawingCanvas test = new DrawingCanvas();

Similar Messages

  • Custom Events and Listeners between classes

    I've got a project I've been working on for weeks that I'm
    having yet another problem with. I'm trying to learn AS3 which is
    why it's taking so long but that's not important for this post.
    I wanted to create a custom event class so that I could make
    sure the event does not interfere with other "COMPLETE" events that
    are being passed between classes. In other words, I have a few
    things that need to complete prior to a function being called...
    one is some XML being loaded and another is a font loaded. So, I
    thought I would create a custom FontLoaded class that extends Event
    and make the type something like "FontLoadedEvent.LOADED". That way
    I could listen for the XML "Event.COMPLETE" and this font event
    also.
    Please tell me if I'm going down the wrong path here but I
    don't seem to be getting the dispatched event for my new custom
    event. Also, how does one detect if it's being dispatched other
    than if the eventListener is fired? Any other ways to test
    this?

    You can trace the event to see if it dispatched.
    Also, this is not a good case to create a new event. Custom
    events are used to store additional information. MouseEvent exists
    because Event doesn't have localX, localY, etc. properties. Since
    you don't seem to be throwing additional properties, you can use a
    regular event.
    trace(dispatchEvent(new Event("panelFontsLoaded"));
    addEventListener("panelFontsLoaded", onFontsLoaded);
    Static consts are used to help debug typos. The event type is
    just a string, often stored in a const.

  • How to insert values into an array of class

    Hello everyone,
    I need help in inserting values into an array of class, which i have read from a file.
    Length of the array is 5. I should insert values one by one into that array.
    If the array is full (if count = 5), then I should split the array into 2 arrays
    and adjust the values to left and right with median.
    I'm getting an ArrayBoundException .. can anybody help me out ?
    Thanks in advance
    Here is my code..........
    import java.util.*;
    import java.io.*;
    public class Tree
         static String second;
         static String first;
         static int count = 5;
         public void insert(int f1,int s1, int c)
              if(c!=0)
                   Record[] rec = new Record[4];
                   for (int i = 0; i < 5; i++)
                          rec[i] = new Record(); 
                   for(int i = 0; i<=4;i++)
                        rec.x = f1;
                        rec[i].y = s1;
              else
                   System.out.println("yes");
         public static void main(String[] args)
              Tree t = new Tree();
              try
                   FileReader fr = new FileReader("output.txt");           // open file
                   BufferedReader br = new BufferedReader(fr);
                   String s;
                   while((s = br.readLine()) != null)
                        StringTokenizer st = new StringTokenizer(s);
                        while(st.hasMoreTokens())
                             first = st.nextToken();
                             second = st.nextToken();
                        //     System.out.println("First-->"+first+" "+"Second-->"+second);
                        int fir = Integer.parseInt(first);
                        int sec = Integer.parseInt(second);
                        t.insert(fir, sec, count);                    
                   fr.close(); // close file           
              catch (IOException e)
    System.out.println("Can't read file");
    class Record
         public int x,y;

    Hi qwedwe.
    Record[] rec = new Record[4];
                   for (int i = 0; i < 5; i++)
                          rec[i] = new Record(); 
                     }Here is your error: you have an array of 4 Records, but you create and (try to) insert 5 Record-instances.... try:
    Record[] rec = new Record[c];
                   for (int i = 0; i < c; i++)
                          rec[i] = new Record(); 
                     }Regards,
    Norman

  • [svn] 839: Moving the SuspendableAMFFilter classes to BlazeDS (and fix an @ author Javadoc tag in the SQLParser.jj grammar).

    Revision: 839
    Author: [email protected]
    Date: 2008-03-17 13:06:58 -0700 (Mon, 17 Mar 2008)
    Log Message:
    Moving the SuspendableAMFFilter classes to BlazeDS (and fix an @author Javadoc tag in the SQLParser.jj grammar).
    Modified Paths:
    blazeds/branches/3.0.x/modules/core/src/java/flex/messaging/services/messaging/selector/S QLParser.jj
    Added Paths:
    blazeds/branches/3.0.x/modules/core/src/java/flex/messaging/endpoints/amf/SuspendableAMFF ilter.java
    blazeds/branches/3.0.x/modules/core/src/java/flex/messaging/endpoints/amf/SuspendableBatc hProcessFilter.java
    blazeds/branches/3.0.x/modules/core/src/java/flex/messaging/endpoints/amf/SuspendableLega cyFilter.java
    blazeds/branches/3.0.x/modules/core/src/java/flex/messaging/endpoints/amf/SuspendableMess ageBrokerFilter.java
    blazeds/branches/3.0.x/modules/core/src/java/flex/messaging/endpoints/amf/SuspendableSeri alizationFilter.java

    Revision: 839
    Author: [email protected]
    Date: 2008-03-17 13:06:58 -0700 (Mon, 17 Mar 2008)
    Log Message:
    Moving the SuspendableAMFFilter classes to BlazeDS (and fix an @author Javadoc tag in the SQLParser.jj grammar).
    Modified Paths:
    blazeds/branches/3.0.x/modules/core/src/java/flex/messaging/services/messaging/selector/S QLParser.jj
    Added Paths:
    blazeds/branches/3.0.x/modules/core/src/java/flex/messaging/endpoints/amf/SuspendableAMFF ilter.java
    blazeds/branches/3.0.x/modules/core/src/java/flex/messaging/endpoints/amf/SuspendableBatc hProcessFilter.java
    blazeds/branches/3.0.x/modules/core/src/java/flex/messaging/endpoints/amf/SuspendableLega cyFilter.java
    blazeds/branches/3.0.x/modules/core/src/java/flex/messaging/endpoints/amf/SuspendableMess ageBrokerFilter.java
    blazeds/branches/3.0.x/modules/core/src/java/flex/messaging/endpoints/amf/SuspendableSeri alizationFilter.java

  • Array of class objects

    I was wondering how would you declare an array of class objects. Here is my situation:
    I'm working on a project dealing with bank accounts. Each customer has a specific ID and a balance. I have to handle transactions for each customer at different times, so I was thinking that I need an array of class objects; however, I dont know how to initialize them.
    Here's what I did:
    BankAccount [ ] myAccount = new BankAccount[10];
    // 10 = 10 customers
    How do I initialize the objects?
    Thankz

    I was wondering how would you declare an array of
    class objects. Here is my situation:
    I'm working on a project dealing with bank accounts.
    Each customer has a specific ID and a balance. I have
    to handle transactions for each customer at different
    times, so I was thinking that I need an array of
    class objects; however, I dont know how to initialize
    them.
    Here's what I did:
    BankAccount [ ] myAccount = new BankAccount[10];
    // 10 = 10 customers
    How do I initialize the objects?
    Thankz
    HAI
    Use the hashtable
    and store the classObject of each customer with the corresponding Id in it
    and whenever u want to recover a class match the Id and get the corresponding class
    that is the best way to solve ur problem
    Regards
    kamal

  • All functions in FUNCLIB record can be moved to Application Class?

    I am new comer for PeopleCode. I find many functions are put into a work record, like FUNCLIB. I want to know if some logics only are able to be coded in work record as function due to some restrictions or convenience. If yes, what are the restrictions and conveniences? If not, any one function in one record can be moved to Application Class? Please help to answer. Thanks in advance.

    My two cents on this is that the FUNCLIB_ convention is a legacy convention, which was rolled out prior to the existence of application packages. As one can imagine, there is a large effort involved in pulling out FUNCLIB_ code and re-directing all of the calls to application classes.
    I work with application classes where possible; there are nice OOP features and things are more tightly defined e.g. you can't just define a bunch of variables and have the '&randomstring is auto-defined' messages appear during PC validation in an App Class.
    If you are writing something new, then I would encourage you to use application packages and classes. If you are thinking of re-writing code that exists in a FUNCLIB record event, then you will just need to ensure that you've identified all the calls and so on.
    Hope this helps
    John

  • Is there any Similar between Class.forName() and new operator ???

    Plz tel me is there any Similar between Class.forName() and new operator ??? i have been asked this ques in interview

    You probably should have used the other thread:
    http://forum.java.sun.com/thread.jspa?threadID=792678
    To add a little confusion to the matter...Class objects are in fact objects. They're objects representing classes. So, in a sense, I guess, you could say they're similar -- in each you get an object. But in practice Class objects and all other objects should be considered semantically different unless you're doing some pretty unusual stuff. Also Class.forName is more of a factory method than a constructor.

  • Diffrence between Class.forName() and new Operator

    What is diffrence between class.forName() and new operator.Please tell in much detail.
    Also about classloader.loadclass.
    Suppose the class that we are tring to load with the help of class.forname is not compiled. Again if I make changes at runtime to that class will that get reflected.

    What is diffrence between class.forName() and new
    operator.Please tell in much detail.Class.forName loads a class. The new operator creates a new instance. Apple trees and apples.
    Also about classloader.loadclass.Read the API.
    Suppose the class that we are tring to load with the
    help of class.forname is not compiled.Then you can't load it and get an exception. Read the API.
    Again if I
    make changes at runtime to that class will that get
    reflected.Depends on the changes and when exactly you do them.

  • Controlling events between classes

    hello
    i know i'm asking a lot, but i couldn't find anything. the problem is i've got a jframe and some panels with buttons.
    eg:
    class A extends JFrame
    getContentPane().add( B ) ;
    getContentPane().add( C ) ;
    class B extends JPanel
    add( button1 ) ;
    add( button2 ) ;
    class C extends JPanel
    add( button3 ) ;
    add( button4 ) ;
    where do i add ActionListeners? how do i pass information between classes? if button1 is clicked -> class A should know it.
    i tried to do this in class A: objectOfB.button1 (access button1 directly) - didn't work - why?
    if a button1 is clicked i want to remove the jpanel and replace it with another one. how should i do this?
    Thank You All

    Check out the java tutorials. There are great examples that show you how to do what you want to do

  • Link between Class and characteristics created for that class

    Hi All,
    Is there any table that I can look at to find a link between class and the characteristics created for that class. For all the list of characteristics created I am refereing to CABN table but my requirement is to find the logic to see all the characteristics created for a class. Can anyone suggest me the right table to look at?
    Regards,
    Shane

    Hi,
    I would like to thank you for your quick response. So based on your thoughts, here is the process i followed to find the characteristics for a existing class,  took the Internal class number and used the KSML table to find all the Characteristics created for that class.
    To find the list of values assigned to that characteristics, used the AUSP table for that characteristics internal number.
    Thank you again for your inputs
    Shane.

  • LR5 stopped moving files between folders

    Hi everybody,
    I've noticed today that my LR5 stopped moving files between folders, I select files I want to move and drag them over to a new location like I always did before with only difference is now nothing happends, no messages with errors, nothing... I tried to google it and couldn't find anything related to my problem.
    I'm using Windows 8 x64. I checked the permissions on all the photo folders and everything seems to be correct. I also run LR under admin rights, so there shouldn't be any OS related issues... in addition, it was working just fine till today.
    I hope you can at least point me in right direction to dig more info on the problem with my LR5.
    Thx!

    Hi everybody,
    I've noticed today that my LR5 stopped moving files between folders, I select files I want to move and drag them over to a new location like I always did before with only difference is now nothing happends, no messages with errors, nothing... I tried to google it and couldn't find anything related to my problem.
    I'm using Windows 8 x64. I checked the permissions on all the photo folders and everything seems to be correct. I also run LR under admin rights, so there shouldn't be any OS related issues... in addition, it was working just fine till today.
    I hope you can at least point me in right direction to dig more info on the problem with my LR5.
    Thx!

  • It stopped sending mail and moving messages between folders, junk messages stopped being moved.

    Recently, Thunderbird stopped sending mail and moving messages between folders, junk messages stopped being moved.

    Further notes (different user, same problem):
    * This is a problem that started in Thunderbird 32
    * This involves both automatic (filter) moves and manual moves
    * This includes use of keys and hotkeys (the delete key, for example)
    * Restarting Thunderbird does seem to "reset" the problem... for a while. I notice the problem most when either I've been away from the computer/program for a while or when waking a laptop computer from a sleep or hibernation state.

  • Why Array.as class is made dynamic?

    Why Array.as class is made dynamic?
    public dynamic class Array

    For one thing, array "elements" are merely dynamic properties. For example, when you access a[0] you are really accessing a["0"], i.e., a dynamic property named "0".
    For another thing, Ecmascript requires Array to allow accessing any property, such as a["foo"].
    Gordon Smith, Adobe

  • Moving apps between screens

    I'm having trouble moving apps between screens. I can move one app but then if I try and move another, I drag it off the side of the screen but the screen doesn't change. The only workaround I have is to move an app to the dock, change the screen with a swipe, then move the app out of the dock back onto the new screen. Is anyone else having this problem?

    I thought this was broken on my iPad after upgrading to iOS 4.2. After messing around, I found that if I move an icon around on the screen and hold it at the edge of the screen for a few extra seconds, with the edge of the icon slightly off the screen. Then the screen will change.

  • Store an Array of Classes e.g. Order / Line Items example

    Hello, I am having trouble storing an array of classes, they all end up having the same value.
    Consider the following simple class definition:
    Class Order
    private LineItem[] lineItems;
    Class LineItem(amount, price)
    private int amount;
    private float price;
    Consider the following pseudo code as part of the constructor of class order (to fill the array with a bunch of LineItems):
    for x = 1 to 10
    lineItems[x] = new LineItem(amount, price);
    however all lineItems[x] have the same LineItem
    any ideas?

    i posted the design since its a bit more complicated then my summarized version, but at any rate i will post the full solution for those who want to view either or...
    basically this takes an XML field and creates an object Order which has some attributes plus an array of Line Item objects.
    import java.util.ArrayList;
    import java.util.HashMap;
    import java.util.Iterator;
    import java.util.List;
    import java.util.Map;
    import org.dom4j.Node;
    import org.dom4j.Document;
    public class SiebelOrder
      private String accountId;
      private String backOfficeOrderNumber;
      private String contactFirstName;
      private String contactId;
      private String contactLastName;
      private String currencyCode;
      private String description;
      private String entryAssociate;
      private String legalEntity;
      private String orderRevenue;
      private String orderDate;
      private String orderNumber;
      private String orderType;
      private String orderTypeId;
      private String primaryOrganization;
      private String primaryServiceRegion;
      private String primaryShipToAddress;
      private String PrimaryShipToAddressId;
      private String PrimaryShipToCity;
      private String PrimaryShipToCountry;
      private String PrimaryShipToPostalCode;
      private String PrimaryShipToState;
      private String RegionAddress;
      private String RegionAddressId;
      private String RegionCity;
      private String RegionCountry;
      private String RegionPostalCode;
      private String RegionState;
      private String Revision;
      private String SalesRecognizedDate;
      private String status;
      private String taxExempt;
      private String taxExemptNumber;
      private String taxExemptReason;
      private SiebelLineItem[] lineItems;
      protected SiebelOrder()
        //default constructor
      protected SiebelOrder(Node pOrderNode)
        //gets the attribute by using an xpath query of the given node
        accountId = pOrderNode.valueOf("//AccountId/text()");
        backOfficeOrderNumber = pOrderNode.valueOf("//BackOfficeOrderNumber/text()");
        contactFirstName = pOrderNode.valueOf("//ContactFirstName/text()");
        contactId = pOrderNode.valueOf("//ContactId/text()");
        contactLastName = pOrderNode.valueOf("//ContactLastName/text()");
        currencyCode = pOrderNode.valueOf("//CurrencyCode/text()");
        description = pOrderNode.valueOf("//Description/text()");
        entryAssociate = pOrderNode.valueOf("//EntryAssociateEMP/text()");
        legalEntity = pOrderNode.valueOf("//LegalntityEMP/text()");
        orderRevenue = pOrderNode.valueOf("//OrderRevenueEMP/text()");
        orderDate = pOrderNode.valueOf("//OrderDate/text()");
        orderNumber = pOrderNode.valueOf("//OrderNumber/text()");
        orderType = pOrderNode.valueOf("//OrderType/text()");
        orderTypeId = pOrderNode.valueOf("//OrderTypeId/text()");
        primaryOrganization = pOrderNode.valueOf("//PrimaryOrganization/text()");
        primaryServiceRegion = pOrderNode.valueOf("//PrimaryServiceRegionEMP/text()");
        primaryShipToAddress = pOrderNode.valueOf("//PrimaryShipToAddress/text()");
        PrimaryShipToAddressId = pOrderNode.valueOf("//PrimaryShipToAddressId/text()");
        PrimaryShipToCity = pOrderNode.valueOf("//PrimaryShipToCity/text()");
        PrimaryShipToCountry = pOrderNode.valueOf("//PrimaryShipToCountry/text()");
        PrimaryShipToPostalCode = pOrderNode.valueOf("//PrimaryShipToPostalCode/text()");
        PrimaryShipToState = pOrderNode.valueOf("//PrimaryShipToState/text()");
        RegionAddress = pOrderNode.valueOf("//RegionAddress/text()");
        RegionAddressId = pOrderNode.valueOf("//RegionAddressId/text()");
        RegionCity = pOrderNode.valueOf("//RegionCity/text()");
        RegionCountry = pOrderNode.valueOf("//RegionCountry/text()");
        RegionPostalCode = pOrderNode.valueOf("//RegionPostalCode/text()");
        RegionState = pOrderNode.valueOf("//RegionState/text()");
        Revision = pOrderNode.valueOf("//RegionRevision/text()");
        SalesRecognizedDate = pOrderNode.valueOf("//SalesRecognizedDateEMP/text()");
        status = pOrderNode.valueOf("//Status/text()");
        taxExempt = pOrderNode.valueOf("//TaxExempt/text()");
        taxExemptNumber = pOrderNode.valueOf("//TaxExemptNumber/text()");
        taxExemptReason = pOrderNode.valueOf("//TaxExemptReason/text()");
        // ----- create line items -----
        //queries the order node using xpath and returns it as a list of line item nodes
        List lineItemList = pOrderNode.selectNodes("//OrderEntry-LineItemsEmp");
        //sizes the array to the number of line items
        lineItems = new SiebelLineItem[lineItemList.size()];
        //update the array to be a list of blank lineitems
        for(int i=0; i < lineItemList.size(); i++)
          lineItems[i] = new SiebelLineItem();
        //store the lineitem details in each array item
        int i = 0;
        for (Iterator iter = lineItemList.iterator(); iter.hasNext(); )
          Node lineItemNode = (Node) iter.next();   
          //  ALL lineItems[i] ARE THE SAME VALUE
          lineItems.setLineDetails(lineItemNode);
    i++;
    import java.util.HashMap;
    import java.util.Map;
    import org.dom4j.Document;
    import org.dom4j.Node;
    public class SiebelLineItem
        private String actualSalesPrice;
        private String costProduct;
        private String ESRPLabor;
        private String inactiveFlag;
        private String installationMethod;
        private String integrationId;
        private String laborOptionFlag;
        private String lineItemType;
        private String lineNumber;
        private String lineSequenceNumber;
        private String lineStatus;
        private String orderHeaderId;
        private String product;
        private String productId;
        private String productSeries;
        private String productStyle;
        private String servicePartFlag;
        private String taxRate;
        private String taxType;
        private String UOMLine;
        private String UOMQuantity;
        private String vendorCode;
        private String vendorName;
      protected SiebelLineItem()
        //default constructor
      protected void setLineDetails(Node pLineItemNode)
        //gets the attribute by using an xpath query of the given node
        actualSalesPrice = pLineItemNode.valueOf("//ActualSalesPriceEMP/text()");   
        costProduct = pLineItemNode.valueOf("//CostProductEMP/text()");
        ESRPLabor = pLineItemNode.valueOf("//ESRPLaborEMP/text()");
        inactiveFlag = pLineItemNode.valueOf("//InactiveFlagEMP/text()");
        installationMethod = pLineItemNode.valueOf("//InstallationMethodEMP/text()");
        integrationId = pLineItemNode.valueOf("//IntegrationIdEMP/text()");
        laborOptionFlag = pLineItemNode.valueOf("//LaborOptionFlagEMP/text()");   
        lineItemType = pLineItemNode.valueOf("//LineItemTypeEMP/text()"); 
        lineNumber = pLineItemNode.valueOf("//LineNumberEMP/text()");
        lineSequenceNumber = pLineItemNode.valueOf("//LineSequenceNumberEMP/text()");
        lineStatus = pLineItemNode.valueOf("//LineStatusEMP/text()");
        orderHeaderId = pLineItemNode.valueOf("//OrderHeaderId/text()");
        product = pLineItemNode.valueOf("//Product/text()");
        productId = pLineItemNode.valueOf("//ProductId/text()");
        productSeries = pLineItemNode.valueOf("//ProductSeriesEMP/text()");
        productStyle = pLineItemNode.valueOf("//ProductStyleEMP/text()");
        servicePartFlag = pLineItemNode.valueOf("//ServicePartFlagEMP/text()");
        taxRate = pLineItemNode.valueOf("//TaxRateEMP/text()");
        taxType = pLineItemNode.valueOf("//TaxTypeEMP/text()");
        UOMLine = pLineItemNode.valueOf("//UOMLineEMP/text()");
        UOMQuantity = pLineItemNode.valueOf("//UOMQuantityEMP/text()");
        vendorCode = pLineItemNode.valueOf("//VendorCodeEMP/text()");
        vendorName = pLineItemNode.valueOf("//VendorNameEMP/text()"); 

Maybe you are looking for