Accessing objects in a different class?

I am now trying to reference a JFileChooser that is in my properties class to a String in my ConfCode class. How would I go about referencing this Object outside of its class? If this makes sense!

If both classes are located in the same directory, you should be able to call them just like any other class you've imported.
//source file Class1.java
public class Class1 {
    public static void main(String[] args) {
     Class2 c2 = new Class2();
     c2.theMethod();
//source file Class2.java
public class Class2 {
    public void theMethod() {
     System.out.println("the method was called!");
}

Similar Messages

  • Accessing object of the main class from the thread

    Hi, I'm having problem accessing object of the main class from the thread. I have only one Thread and I'm calling log.append() from the Thread. Object log is defined and inicialized in the main class like this:
    public Text log;  // Text is SWT component
    log = new Text(...);Here is a Thread code:
    ...while((line = br.readLine())!=null) {
         try {
              log.append(line + "\r\n");
         } catch (SWTException swte) {
              ErrorMsg("SWT error: "+swte.getMessage());
    }Error is: org.eclipse.swt.SWTException: Invalid thread access
    When I replace log.append(...) with System.out.println(..) it works just fine, so my question is do the log.append(..) the right way.

    This is NOT a Java problem but a SWT specific issue.
    It is listed on the SWT FAQ page http://www.eclipse.org/swt/faq.php#uithread
    For more help with this you need to ask your question on a SWT specific forum, there is not a thing in these forums. This advice isn't just about SWT by the way but for all specific API exceptions/problems. You should take those questions to the forum or mailing list for that API. This forum is for general problems and exceptions arising from using the "core" Java libraries.

  • Access oracle database from different classes in desktop / standalone app.

    I am a bit confused as to what way to go. I am building a desktop application that needs to access an oracle database. I have done this in the past using code similar to the following:
            try {             DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());             Connection conn = DriverManager.getConnection(                     "jdbc:oracle:thin:@111.111.111.111:oracledb",                     "username", "password" );             // Create a Statement             Statement stmt = conn.createStatement();             ResultSet rs = stmt.executeQuery(                     "select ... from ...");             while (rs.next()) {                 ReportNumberCombo.addItem(rs.getString(1));             } // end of rs while             conn.close();         } //  end of try         catch( Exception e ) {             e.printStackTrace();         }
    The problem I would like to resolve is that I have this code all over the place in my application. I would like to have it in one objects method that i can call from other classes. I can't easily see how to do this, or maybe at this point I'm just too confused.
    I want to be able to change this connection info from a properties file which I have already done, not sure if this bit of information would change the answer to my question. I was also looking at the DataSource api, this looks like it is close to what I should use, what are your thoughts?
    I would also like to if JNDI is only for web applications or would be appropriate for a desktop app.
    Thank you for your help, I realize this is all over the place but I really need these topics cleared up!

    I have tried exactly that and am getting an error which let me to believe it couldn't be done that way. Here is my code and error message:
    public class readPropsFile {
        String getURL() throws IOException {
            // default values for properties file
            String Family = "Family:jdbc" + ":oracle:" + "thin:@";
            String Server = "Server:111.111.111.111";
            String Port = "Port:1521";
            String Host = "Host:oradb";
            String Username = "Username:username";
            String Password = "Password:password";
            try {          
                new BufferedReader(new FileReader("C:\\data\\Properties.txt"));
            } catch (FileNotFoundException filenotfound) {
                System.out.println("Error: " + filenotfound.getMessage());
                // displays to console if file DOES NOT exist
                System.out.println("The file DOES NOT exist, now creating...");
                FileWriter fileObject = null;
                fileObject = new FileWriter("c:\\data\\Properties.txt");
                BufferedWriter out = new BufferedWriter(fileObject);
                // writes to output as simple text.
                out.write(Family);
                out.newLine();
                out.write(Server);
                out.newLine();
                out.write(Port);
                out.newLine();
                out.write(Host);
                out.newLine();
                out.write(Username);
                out.newLine();
                out.write(Password);
                out.newLine();
                out.close();
            // displays to console if file exists
            System.out.println("The file exists, or was created sucessfully");
    //      creates the properties object, assigns text file.
            Properties props = new Properties();
            FileInputStream in = new FileInputStream("c:\\data\\Properties.txt");
            props.load(in);
            Family = props.getProperty("Family");
            Server = props.getProperty("Server");
            Port = props.getProperty("Port");
            Host = props.getProperty("Host");
            Username = props.getProperty("Username");
            Password = props.getProperty("Password");
    //      prints properties to a file for troubleshooting
            PrintStream s = new PrintStream("c:\\data\\list.txt");
            props.list(s);
            in.close();
            String URL = "\"" + Family + Server + ":" + Port + ":" + Host + "\"" +
                    "," + "\"" + Username + "\"" + "," + "\"" + Password + "\"";
            System.out.println("This is the URL:" + URL);
            return URL;
    }And here is where I try to call the method:
    public class connWithProps1 {
        public static void main(String[] args) {
            readPropsFile callProps = new readPropsFile();
            try {
                callProps.getURL();
                String url = callProps.getURL(); // not needed
                System.out.println("The URL (in connWithProps1) is: " + csoProps.getURL());
                DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
                Connection conn = DriverManager.getConnection(url);
                // Create a Statement
                Statement stmt = conn.createStatement();
                ResultSet rs = stmt.executeQuery("select .... WHERE ....'");
                while (rs.next()) {
                    System.out.println(rs.getString(1));
                } // end of rs while
                conn.close();
            } catch (SQLException sqle) {
                Logger.getLogger(connWithProps1.class.getName()).log(Level.SEVERE, null, sqle);
            } catch (IOException ioe) {
                Logger.getLogger(connWithProps1.class.getName()).log(Level.SEVERE, null, ioe);
    }The error I get is:
    SEVERE: null
    java.sql.SQLException: Listener refused the connection with the following error:
    ORA-12505, TNS:listener does not currently know of SID given in connect descriptor
    The Connection descriptor used by the client was:
    111.111.111.111:1521:oradb","username","password"
            at oracle.jdbc.driver.SQLStateMapping.newSQLException(SQLStateMapping.java:70)
            at oracle.jdbc.driver.DatabaseError.newSQLException(DatabaseError.java:112)
            at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:173)
            at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:460)
            at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:411)
            at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:490)
            at oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:202)
            at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:33)
            at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:474)
    {code}
    Although the URL prints out correctly and when I tried plugging in the URL manually, it works just fine. One other thing I noticed was the line "The file exists, or was created sucessfully" is output 3 times.
    I will go back and change my code to properly close the resultset, thanks for catching that. Id rather use what I have instead of JNDI unless it's nesessary.
    Edited by: shadow_coder on Jun 19, 2009 2:16 PM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • AIR 3.4: Access Object reference from different sandbox

    I have an application that loads a local HTML-Page which contains an iFrame displaying a remote website:
    <iframe id="iframe" width="100%" height="100%" style="margin:0;padding:0;" frameBorder="0" documentRoot="app:/www/" sandboxRoot="http://remoteserver.com/mypage" allowCrossDomainXHR="allowCrossDomainXHR" ondominitialize="engageBridge()" > <p>Your browser does not support iFrames. Learning object cannot be loaded.<p> </iframe>
    The Website in the iframe should be able to access a JS-Variable in the local HTML. Is this possible?
    I read the articles about Cross-Scripting between sandboxes and parent-child-bridges, but as far as I understood it this is only for simple objects, which are stringified and then parsed again. What I need is a direct links from the remote website to the Javascript in the local page!

    Hi Pete,
    To package your app with a provisioning profile (enabled with Apple Push Notifications Services) you don't have to provide the application identifier and keychain-access-groups in the entitlements .Just the following entitlements will work :
    <Entitlements>
                <![CDATA[
                           <key>aps-environment</key>
                           <string>development</string>
                ]]>
    </Entitlements>
    instead you've to provide the app-id in the <id> tag of the app-xml like just another AIR-iOS app(I know that Flash Builder changes the app-id to "app-name.debug" but you can change it while packaging and one strong reason to recommend this way is that for the testing I have uploaded a test app at app-store to validate these entitlements and Apple has approved it.) in following way:
    <id>com.kiwiworks.cnn</key> //Remove the Bundle Seed ID from here.
    If you've any questions then please feel free to ask.
    -Nimisha

  • How to access form objects from different class?

    Hello, I am new to java and i started with netbeans 6 beta,
    when i create java form application from template i get 2 classes one ends with APP and one with VIEW,
    i put for example jTextField1 with the form designer to the form and i can manipulate it's contents easily from within it's class (let's say it is MyAppView).
    Question>
    How can i access jTextField1 value from different class that i created in the same project?
    please help. and sorry for such newbie question.
    Thanks Mike

    hmm now it says
    non static variable jTree1 can not be referenced from static context
    My code in ClasWithFormObjects is
    public static void setTreeModel (DefaultMutableTreeNode treemodel){
    jTree1.setModel(new DefaultTreeModel(treemodel));
    and in Class2 it is
    ClasWithFormObjects.setTreeModel(model);

  • Two equal objects, but different classes?

    When programming on binding Referenceable object with JDK version 1.5.0_06, I have encountered a very strange phenomenon: two objects are equal, but they belong to different classes!!!
    The source codes of the program bind_ref.java are listed as below:
    +++++++++++++++++++++++++++++++++++++++++++++++++++++++
    import java.lang.*;
    import java.io.*;
    import java.util.*;
    import javax.naming.*;
    import javax.naming.spi.ObjectFactory;
    import java.util.Hashtable;
    public class bind_ref {
    public static void main( String[] args ) {
    // Set up environment for creating the initial context
    Hashtable env = new Hashtable();
    env.put( Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.fscontext.RefFSContextFactory" );
    env.put( Context.PROVIDER_URL, "file:/daniel/" );
    Context ctx = null;
    File f = null;
    Fruit fruit1 = null, fruit2 = null;
    byte [] b = new byte[10];
    try {
    ctx = new InitialContext( env );
    Hashtable the_env = ctx.getEnvironment();
    Object [] keys = the_env.keySet().toArray();
    int key_sz = keys.length;
    fruit1 = new Fruit( "Orange" );
         SubReference ref1 = fruit1.getReference();
    ctx.rebind( "reference", fruit1 );
         fruit2 = ( Fruit )ctx.lookup( "reference" );
         System.out.println( "ref1's class = (" + ref1.getClass().toString() + ")" );
         System.out.println( "fruit2.myRef's class = (" + fruit2.myRef.getClass().toString() + ")" );
         System.out.println( "( ref1 instanceof SubReference ) = " + ( ref1 instanceof SubReference ) );
         System.out.println( "( fruit2.myRef instanceof SubReference ) = " + ( fruit2.myRef instanceof SubReference ) );
         System.out.println( "ref1.hashCode = " + ref1.hashCode() + ", fruit2.myRef.hashCode = " + fruit2.myRef.hashCode() );
         System.out.println( "ref1.equals( fruit2.myRef ) = " + ref1.equals( fruit2.myRef ) );
    } catch( Exception ne ) {
    System.err.println( "Exception: " + ne.toString() );
    System.exit( -1 );
    +++++++++++++++++++++++++++++++++++++++++++++++++++++++
    All the outputs are shown as below:
    =======================================================
    Fruit: I am created at Mon Jun 18 11:35:13 GMT+08:00 2007
    SubReference: I am created at Mon Jun 18 11:35:13 GMT+08:00 2007
    --------- (i)subref.hashCode() = (-1759114666)
    SubReference: I am created at Mon Jun 18 11:35:13 GMT+08:00 2007
    --------- (i)subref.hashCode() = (-1759114666)
    FruitFactory: obj's class = (class javax.naming.Reference)
    FruitFactory: obj's hashCode = -1759114666
    FruitFactory: obj = (Reference Class Name: Fruit
    Type: fruit
    Content: Orange
    FruitFactory: ( obj instanceof SubReference ) = false
    FruitFactory: subref_class_name = (Fruit)
    Fruit: I am created at Mon Jun 18 11:35:13 GMT+08:00 2007
    ref1's class = (class SubReference)
    fruit2.myRef's class = (class javax.naming.Reference)
    ( ref1 instanceof SubReference ) = true
    ( fruit2.myRef instanceof SubReference ) = false
    ref1.hashCode = -1759114666, fruit2.myRef.hashCode = -1759114666
    ref1.equals( fruit2.myRef ) = true
    ========================================================
    I hightlight the critical codes and outputs related to the strangeness with bold texts.
    Who can tell me what happens? Is it really possible that two objects belonging to different classes are equal? If so, why that?

    It can also depend on how you implement the equals method.
    class Cat {
        String name;
        Cat(String n) {
            name = n;
    class Dog {
        String name;
        Dog(String n) {
            name = n;
        public boolean equals(Object o) {
            return name.equals(o.name);
        public static void main(String[] args) {
            Dog d = new Dog("Fred");
            Cat c = new Cat("Fred");
            System.out.println(d.equals(c));
    }

  • What's the best way to organize a sequence of objects of different classes

    Say I have a base class and some derived classes... lots of different derived classes, actually. I need to create many objects from all sorts of these subclasses and put them onto a LIFO sequence. What's the ideal type of collection to handle this? I'd also like to shuffle and pop elements, as well. I know about Vectors and Stacks, but I am wondering... Is it possible to have different types of these objects floating around in them? Would I have to use generics?
    I know you can create a list of the superclass and simply cast it to that, but I read that was bad practice.

    mhoribe wrote:
    I see.
    Let me ask you this. What, exactly, goes on when casting? If I add new methods and field to a subclass and cast it back to the base class, will I get any trouble using methods and fields? Or does Java simply allow this for simplicity sake. Like, we know it's a base class, but I'll allow you to call it a superclass just so it will be compatible and simple. Kinda get what I'm going for here?You never need to cast something to a super. Every instance of a subclass IS and instance of all its superclasses and interfaces.
    However, if you're adding new methods and fields to a subclass, there's a good chance you're subclassing for the wrong reasons, and especially if you're storing objects of these various classes in the same data structure but not treating them as a common parent type, you probably have a broken design.

  • Confusion... Data Access Object and Collection Class

    Please help me...
    i have a Book class in the library system, so normally i would have a Collection class eg. BookCollection class which keeps an array/ arrayList of Book objects. In BookCollection class i have methods like
    "searchBook(BookID)" which would return me a Book object in the array.
    But now i'm confused with Data Access Object... In sequence diagrams there's a "Data Access class" which is used to retrieve data from and send data to a database. So, if i have the Data Access class, do i still need BookCollection class? Because BookCollection serves as a database also rite? ...

    I think you're in the right rail.
    The BookCollection class could be still usefull if you will need to manage search results with more than onne record (e.g.: search by author name).

  • Accessing a different class using ActionPerformed

    hi
    im trying to access a method in a different class using
    public void actionPerformed (ActionEvent e) {
              if(e.getSource() == AuthorCombo) {
                   ComboAction();
              else if(e.getSource() == SearchButton){
                        SearchSystem();
    }and then using
    public class Book extends ViewPanel{
    public void SearchSystem(){// this is used to get the information from
                      //the combo boxs whixh can latter show
                      //the data in the text area
    tempBookNoList.clear();
              for(int a=0; a<AuthorList.size(); a++) {
                                  if(((String)AuthorCombo.getSelectedItem()
                                  ==AuthorList.get(a))
                                  &&((String)BookCombo.getSelectedItem()
                                  ==BookList.get(a))) {
                                       tempBookNoList.add((String)BookNoList.get(a));
                        String result = (String)tempBookNoList.get(a);
                        InfoArea.setText ((String)tempBookNoList.get(a));
    }          }//End neither random situation.to manipulate some data within the other class
    i keep getting the error
    .\ViewPanel.java:314: cannot resolve symbol
    symbol : method SearchSystem ()
    location: class ViewPanel
                        SearchSystem();
    ^
    1 error
    can anyone help me spot the problem

    in that case i do not know what could be the cause in this program
    the only area i think it could be is when the SearchSystem method in the Book class gets using the Action Performed method in the Viewpanel method, shown below
    public class Book extends ViewPanel{
    public void SearchSystem(){// this is used to get the information from
                      //the combo boxs whixh can latter show
                      //the data in the text area
              for(int a=0; a<AuthorList.size(); a++) {
                                  if(((String)AuthorCombo.getSelectedItem()
                                  ==AuthorList.get(a))
                                  &&((String)BookCombo.getSelectedItem()
                                  ==BookList.get(a))) {
                                  InfoArea.setText((String)BookNoList.get(a));
                   }which is called using
    public void actionPerformed (ActionEvent e) {
              if(e.getSource() == AuthorCombo) {
                   ComboAction();
              else if(e.getSource() == SearchButton){
                        theBook.SearchSystem();
    }but i cant see this being a problem as it all compiles

  • When it's required to share a single object in different classes????

    Hi friends...
    I am new to java programming language....
    when it is required to share a single object in different classes???
    and
    please give me one example with explanation...
    Thank you
    regards Shree

    sun_shree wrote:
    Thanks for all giving reply.....
    please write the constructor which is accepting reference and please,,,,,, explain......
    Thanking youNo.
    This will be covered in any Java textbook or tutorial. Like this one: [http://java.sun.com/docs/books/tutorial/java/javaOO/arguments.html]
    After reading it and writing some code of your own to test your understanding, if you still have a specific question, post again.

  • Sorting a list of different class objects

    Hi All ,
    How to sort a List a.which contains objects of different Classes, b. objects of same class . Is it possible to sort these by implementing Comparable interface .
    Thanks ,
    Rajesh Reddy

    rajeshreddyk wrote:
    Hi All ,
    How to sort a List a.which contains objects of different Classes, b. objects of same class . Is it possible to sort these by implementing Comparable interface .Well, if objects of different classes are kept in the same List and you want to sort them together they at least have that in common. They're Comparable-able. -:) To manifest that the different classes could all implement a Comparableable interface (or maybe Intercomparable would be a better choise of name.)

  • Accessing an object from a different server

    Hi,
    I am making a program that will access an object from a different server.
    I have a program that when I run calls a jsp page running on Server A which in turn should request an object A from Server B.
    I am relatively new to Java and jsp. What would my best course of action be.
    Thanks in advance,
    Brian

    Or RMI?OK, sounds good, I will look up some RMi on the site.
    Thanks, will prob have more questions for you later.

  • While running my app I get the below error  - have different Class objects for the type javax/servlet/http/HttpServletRequest used in the signature

    I am running ATG[10.1.2] app on Jboss [EAP 5.1.0 GA] I am able to open dyn/admin however when I start my app I get the below error
    java.lang.LinkageError: loader constraint violation: when resolving method "atg.servlet.ServletUtil.setSessionConfNumCacheRequest(Ljavax/servlet/http/HttpServletRequest;)Ljavax/servlet/http/HttpServletRequest;" the class loader (instance of org/jboss/classloader/spi/base/BaseClassLoader) of the current class, atg/filter/dspjsp/PageFilter, and the class loader (instance of org/jboss/classloader/spi/base/BaseClassLoader) for resolved class, atg/servlet/ServletUtil, have different Class objects for the type javax/servlet/http/HttpServletRequest used in the signature
      at atg.filter.dspjsp.PageFilter.doFilter(PageFilter.java:215)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      at atg.servlet.ForwardFilter.doFilter(ForwardFilter.java:263)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      at atg.servlet.ErrorFilter.doFilter(ErrorFilter.java:279)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:638)
      at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:446)
      at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:382)
      at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:310)
      at org.apache.catalina.core.StandardHostValve.custom(StandardHostValve.java:416)
      at org.apache.catalina.core.StandardHostValve.status(StandardHostValve.java:342)
      at org.apache.catalina.core.StandardHostValve.throwable(StandardHostValve.java:286)
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:141)
      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
      at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:158)
      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:330)
      at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:829)
      at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:598)
      at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
      at java.lang.Thread.run(Thread.java:680)
    11:22:47,413 ERROR [[localhost]] Exception Processing ErrorPage[errorCode=500, location=/global/errorPage500.jsp]

    The supported JBoss version for 10.1.2 is JBoss EAP 5.1.2 but I don't think that your issue is caused because of this. Your issue is more of an environmental thing as you are probably getting two different versions getting loaded of class javax.servlet.http.HttpServletRequest and so correspondingly two different Class objects as the error shows. One reason for this could be if you include any server-specific libraries (in present case the Servlet API JAR which contains the class javax.servlet.http.HttpServletRequest) of a different version in the /WEB-INF/lib of your web application. Try removing it from there if so and see if that helps.

  • Accessing XML data from a different class

    Hi all,
    I have an xml class that loads xml data, I need to access the data from another class. I have imported the xml classinto the new class and created a new instance of it. However when I try to access the xml data it is coming back as null. I understand this is almost certainly because when it is called the xml data hasn't completed it's load. How can I get round this?
    xml class:
    package {
        import flash.xml.*;
        import flash.events.*;
        import flash.net.*
        import flash.display.*
        public class xml extends MovieClip
            public var xmlRequest:URLRequest;
            public var xmlLoader:URLLoader;
            public var xmlImages:XML;
            public function xml()
                xmlRequest = new URLRequest("images.xml");
                xmlLoader = new URLLoader(xmlRequest)
                xmlLoader.addEventListener(Event.COMPLETE, xmlLoaded);
                xmlLoader.load(xmlRequest);
            private function xmlLoaded(event:Event):void
                trace(xmlLoader.data);
                xmlImages = new XML(xmlLoader.data);
    Thanks in advance

    One of the ways:
    package {
         import flash.xml.*;
        import flash.events.*;
        import flash.net.*
        import flash.display.*
        public class XMLLoader extends EventDispatcher
              public var xmlRequest:URLRequest;
              public var xmlLoader:URLLoader;
              public var xmlImages:XML;
              public function XMLLoader()
              public function loadXML(url:String):void {
                   xmlLoader = new URLLoader()
                   xmlLoader.addEventListener(Event.COMPLETE, xmlLoaded);
                   xmlLoader.load(new URLRequest(url));
              private function xmlLoaded(event:Event):void
                   trace(xmlLoader.data);
                   xmlImages = new XML(xmlLoader.data);
                   dispatchEvent(event);
    Usage:
    var xmlLoader:XMLLoader = new XMLLoader();
    xmlLoader.addEventListener(Event.COMPLETE, onXMLLoad);
    xmlLoader.loadXML("images.xml"):
    function onXMLLoad(e:Event):void{
         trace(xmlLoader.xmlImages);

  • How do I access a gui component in a different class?

    I have a jpanel (mainwindow) in a japplet. mainwindow loads and displays a jpanel form (content1). How do I code a button on conent1 so that mainwindow loads and displays a different jpanel form(content2)? mainwindow, content1, and content2 are all in different classes/packages. Thanks in advance!

    Let your JPanel content1 forward its ActionEvents to its parent. For instance, you could define your content1 as follows:
    public class Content1 extends JPanel
        private ArrayList<ActionListener> actionListeners;
        private JButton myButton;
              public Content1()
             actionListeners = new ArrayList<ActionListener>();
             myButton = new JButton("Test");
             myButton.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent e) {
                             forwardAction(e);
              public void addActionListener(ActionListener listener) {
             actionListeners.add(listener);
        protected void forwardAction(ActionEvent e) {
          for (ActionListener l: actionListeners) {
               l.actionPerformed(e);
    }Then you could let your mainWindow listen to content1:
    // in your main windows' code:
    Content1 content1 = new Content1();
    content1.addActionListener(new ActionListener() {
         public void actionPerformed(ActionEvent e) {
              swapPane(e);    // create a method swapPane in your mainwindow that handles the switch to content2.
    });

Maybe you are looking for

  • HT4061 since downloading IS07 I can no longer send emails via hotmail on my Iphone 5

    Since downloading IOS7 to my iphone 5 I can no longer send emails via my hotmail account  - receiving ok though.  How can I fix this?

  • Using Function module to calculate date

    Hi, I need to use an exit variable in Bex in order to dynamically add or substract months, days, and years from another input variable and have a date interval. After searching, i found that the FM   RP_CALC_DATE_IN_INTERVAL is exactly what i'm searc

  • Need help in ADF Programming

    Hi Team, I am using Jdev 11.1.2.3.0 I have some doubts in ADF programming. Please explain with clear steps 1) How to access VORowImpl method or EORowImpl method from AM and AM method from VO or EO. 2) How to access AM instance from some other AMImpl

  • Passing values to standard screen from  an my internal

    Hi Experts, I want to pass values to the mb51 screen from my own internal table. in the program for mb51 there is include programLMIGOTV4 where what is use of following PBO module before start of LOOP. METHOD pbo. CALL METHOD super->pbo. tv_goitem-li

  • App store isnt working on mac!

    it disappeared then i found it in the trash and when i dragged it out, the icon isnt there anymore and when i click to open it it says "You can't open the application App Store because it may be damaged or incomplete." what should i do????