Variable Class Names?

My current project uses a Movie Class and a Frame Class (amongst others)
I need to create multiple instances of the Frame Class.
Frame frame1 = new Frame(s, n);
Frame frame2 = new Frame(s, n); etc...
is it possible to do 'something like'
Frame frame+i = new Frame(s, n);?
All help is greatly appreciated, thanks.

And if you don't know ahead of time how many Frames there will be:
List<Frame> frameList = new ArrayList<Frame>();
while (there are more Frames to be added) {
  frameList.add(the next frame);
}[http://java.sun.com/docs/books/tutorial/collections/]

Similar Messages

  • Variable class names,QUESTION

    how do I get information from a class using a String for the class name? (in an applet)

    whether you are in an applet or java application, just use Class.forName to retrieve a java.lang.Class instance for that class- then you can get field or method informaiton. There are additional security restrictions in applets, so you may not have access to the particular class, but, if it is accessible, java.lang.Class.forName("yourClassName") is the best choice.

  • QUESTION, variable class names!!!

    I've tried to use Class.forName(variableName) to load a class using a String, but during compilation, I get an error. The variable variableName isn't defined in java.lang.Class. Is this an applet problem or is my program messed?

    paste some code around the line
    Class.forName(variableName);
    especially how you define variableName.
    --lichu                                                                                                                                                                                                                                       

  • AS3 - dynamic class names with *new* operator

    I'm using AcrtionScript 3 and Adobe Flash 9 Public Alpha.
    I have 50 movie clips in the Library that use Linkage to set
    the Class name to: Img1, Img2, Img3, ..., Img50.
    I have a parent class named RandImg. I want the constructor
    for RandImg to randomly select one of the 50 movie clips from the
    Library and display it. I could get this working by generating a
    random number, and then writing a really huge switch statement to
    associate each possible random number with its respective Library
    Movie Clip Class name, but I would much rather do this with a
    dynamic/variable class name based on the random number, such as:
    var nImgChoice:Number = Math.floor( Math.random( ) * 50 ) +
    1;
    var mcImg:MovieClip = new [ "Img"+String(nImgChoice) ] ( );
    addChild( mcImg );
    Note that this used to be possible in AS 2 by doing the
    following:
    this.attachMovie( "Img"+String(nImgChoice) , "mcImg",
    this.getNextHighestDepth());
    Suggestions?
    Thanks,
    ~JC

    import flash.display.DisplayObject;
    import flash.display.Sprite;
    import flash.utils.getDefinitionByName;
    var nImgChoice:Number = Math.floor( Math.random( ) * 50 ) +
    1;
    var ClassReference:Class =
    getDefinitionByName("Img"+String(nImgChoice) ) as
    Class;
    var instance:Object = new ClassReference();
    addChild(DisplayObject(instance));

  • Declare a variable typed "name of a class"-Need help

    I have "segment" class in package named Ex13
    import Exercise12.Point123;
    public class segment {
         private Point123 start;
         private Point123 end;
         public segment(Point123 start, Point123 end) {
              this.start = start;
              this.end = end;
         public double length() {
              return start.distance(end.getX(), end.getY());
         public String midlePoint() {
              return (end.getX() + start.getX()) / 2 + " "
                        + (end.getY() + start.getY()) / 2;
              // return insidePoint(1,1);
         public Point123 insidePoint(double m, double n) {
              double ratio = m / (m + n);
              return new Point123(start.getX()+(end.getX() - start.getX()) * ratio,
                        start.getY()+(end.getY() - start.getY()) * ratio);
    //return (start.getX()+(end.getX() - start.getX())*ratio);
    }And class "Point123" in package Ex12:
    public class Point123 {
         private double x;
         private double y;
         public Point123(double xAsis, double yAsis) {
              x = xAsis;
              y = yAsis;
         public double getX() {
              return x;
         public double getY() {
              return y;
    //     public String toString() {
    //          return String.format("%.1f,%.1f", x, y);
         public boolean isOrigin() {
              return x == 0 && y == 0;
         public boolean isOnX_Axis() {
              return y == 0;
         public boolean isOnY_Axis() {
              return x == 0;
         public double distance(double xAsis, double yAsis) {
              return Math.sqrt(Math.pow(xAsis - x, 2) + Math.pow(yAsis - y, 2));
    }I remove toString method in Point123 class, but whenever I call insidePoint method in segment class it print out "Exercise12.Point123@addbf1". In other hand, I don't remove toString method, I call insidePoint method,then it prints out the correct result which I want.
    I think the reason why this thing happened is that I am using Point123 return type in insidePoint method. To midlePoint method in segment class, it does not affect whether I remove toString or not. That is because I use its own String return type.
    Can someone tells me whether my thought is correct or not? And explain more about variable typed "name of a class"

    Oh! My header's segment class does not have extend...., therefore it inherit from the Object. But what is Object in my class?
    is it "*s*" in my code?
    public class DisplayResult {
         public static void main(String[] args) {
                   segment s  = new segment(new Point123(3,4), new Point123(6,7));
                   System.out.println(s.length());
                   System.out.println(s.midlePoint());
                   System.out.println(s.insidePoint(1.5,4));
    }

  • Undefined variable or class name

    I am trying to call a java class to another class but gets the error: "Undefined variable or class name"
    Both my java files are in the same directory and I am able to compile only one of the program. Wondering what am I missing?
    The source code is:
    ServletUtilities.java: (I am able to compile)
    import java.io.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    public class ServletUtilities {
    public static final String DOCTYPE =
         "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 " +
         "Transitional//EN\">";
    public static String headWithTitle(String title) {
         return(DOCTYPE + "\n" +
              "<HTML>\n" +
              "<head><title>" + title + "</title></head>\n");
    HelloWWW3.java (getting error when compile)
    public class HelloWWW3 extends HttpServlet {
    public void doGet(HttpServletRequest request,
                   HttpServletResponse response)
         throws ServletException, IOException
         response.setContentType("text/html");
    PrintWriter out = response.getWriter();
    out.println(ServletUtilities.headWithTitle("Hello WWW") +
              "<body>\n" +
              "<h1>Hello WWW</h1>\n" +
              "</body></html>");

    I tried and I got these errors:
    C:\java servlets\HelloWWW3\src>javac -classpath . HelloWWW3.java
    HelloWWW3.java:4: Package javax.servlet not found in import.
    import javax.servlet.*;
    ^
    HelloWWW3.java:5: Package javax.servlet.http not found in import.
    import javax.servlet.http.*;
    ^
    HelloWWW3.java:7: Superclass coreservlets.HttpServlet of class coreservlets.Hell
    oWWW3 not found.
    public class HelloWWW3 extends HttpServlet
    ^
    3 errors
    Then I moved HelloWWW3.java and ServletUtilities.class file to C:\jakarta-tomcat-3.2.3\lib
    This dir has files
    JAXP JAR
    SERVLET JAR
    ANT JAR
    PARSER JAR
    WEBSER~1 JAR
    JASPER JAR
    and compiled and got this error
    C:\jakarta-tomcat-3.2.3\lib>javac -classpath . HelloWWW3.java
    HelloWWW3.java:4: Package javax.servlet not found in import.
    import javax.servlet.*;
    ^
    HelloWWW3.java:5: Package javax.servlet.http not found in import.
    import javax.servlet.http.*;
    ^
    HelloWWW3.java:7: Superclass coreservlets.HttpServlet of class coreservlets.Hell
    oWWW3 not found.
    public class HelloWWW3 extends HttpServlet
    ^
    3 errors
    Here is what I hava defined for my CLASSPATH
    C:\jakarta-tomcat-3.2.3\lib>echo %CLASSPATH%
    C:\jakarta-tomcat-3.2.3\lib\servlet.jar;C:\jakarta-tomcat-3.2.3\lib\jasper.jar
    ------------------------------------------

  • Undefined variable, class, or package name

    The following code in the jsp is supposed to display the correct 'Securities' link based on the app_main_frames URL. I am getting an error. Can anyone help?
    <% if (parent.app_main_frame.location == ("http://ccmsun57.ccminvest.com:8080/cgi-java/Allocation/jsp/scenario.jsp?source=init")) { %>
    Securities
    <% } else { %>
    <a href="/cgi-java/Holdings/jsp/SecurityInventoryQuery.jsp?which_search=none&which_category=none
    target="app_main_frame">Securities</a>
    <% } %>
    I am getting the following error:
    Generated servlet error:
    /opt/JBoss-2.4.4_Tomcat-4.0.1/catalina/work/localhost/cgi-java/common/jsp/NavigationMenu$jsp.java:173:
    Undefined variable, class, or package name: parent
    if (parent.app_main_frame.location ==
    ^
    ("http://ccmsun57.ccminvest.com:8080/cgi-java/Allocation/jsp/scenario.jsp?source=init")) {

    If app_main_frame is a frame in a frameset then you cannot
    simply refer to it in a Java scriptlet.
    You can refer to it in a JavaScript script, like this:
    <script>
    if (parent.app_main_frame.location == "http://ccmsun57.ccminvest.com:8080/cgi-java/Allocation/jsp/scenario.jsp?source=init")
       document.write("<a href=\"javascript:submit_Form('none')\"target=\"app_main_frame\">Securities</a>");
    else
       document.write("<a href=\"/cgi-java/Holdings/jsp/SecurityInventoryQuery.jsp?which_search=none&which_category=none\"target=\"app_main_frame">Securities</a>");
    </script>

  • How to convert a String variable as class name and method name?

    i have two classes
    class Student
    public String insertStudent(String sname)
    { return("Student has been inserted ");     }
    class Teacher
    public String execute(String methodName, String className)
    {  //return statement of the method 'insertStudent' in the class 'Student'; }
    }Now, i have a class with the main method. Here, i would like to call the method *'insertStudent'* of class *'Student'*
    using the method *'execute'* of class *'Teacher',* passing the method-name and the class-name (viz. insertStudent, Student) as the
    String parameter.
    Can anyone please help me out. Thanks
    regards,
    chinglai

    You should have just added that as a comment on your [initial posting|http://forums.sun.com/thread.jspa?threadID=5334953] instead of starting a new thread.
    Now, i have a class with the main method. Here, i would like to call the method 'insertStudent' of class 'Student'using the method 'execute' of class 'Teacher', passing the method-name and the class-name (viz. insertStudent, Student) as the
    String parameter.
    Why oh why? What do you want to achieve?
    Let me tell you: there is a way to do what you try to do, but it's not recommended and should be used only very sparingly. Especially not in anything like your code, that resembles normal business logic (as opposed to an application framework such as Spring, for example).
    Can you explain what exactly you want to do with that? Why should a Teacher be able to call any random method ony any other class. And what good would that do?

  • Can you determine a dragged objects Class Name when it is dropped?

    Is there a way to determine the class name for a dragged object.
    I have set up two objects. One is a JList that acts as a data source for the second object which is a JTable. Both objects serve as both drag source and drop targets. I need to be able to react to the following events:
    1. Drag value from JList to JTable.
    2. Drag value from JTable to JTable (itself) to reposition order.
    3. Drag value from JTable to JList (deletes item from JTable).
    So far, I have had no problem in getting #1 to work.
    The problem is determining how to consistently interpret which event is happening for 2 and 3. Both the drop (DropTargetDropEvent event) and the dragDropEnd (DragSourceDropEvent event) are fired for either 2 or 3 above. If I could identify the source class for the dragsource and the target class for the droptarget, the coding would be easy. I haven't been able to find anything on this while reviewing the API documentation.
    Any help would be appreciated.
    Thanks

    No, there are not multiple policies - the host names for all aliases on that single webserver are together in a single host identifier. And I realize I can only have a single challenge redirect, I just want to use a variable to redirect to the host name that was accessed as opposed to a static name.

  • Error in File name or class name not found during Automation operation: 'CreateObj​ect'

    Hello Team,
    When I am trying to execute the below code i am getting the following error. Any help would be greatly appreciated.
    Set oFSO = CreateObject("Scripting.FileSystemObject")
    If Not oFSO.FolderExists(SavePath) Then
    Set f = oFSO.CreateFolder(SavePath)
    Else
    End If
    53 4/11/2014 12:27:22 PM Error:
    Error in <NoName(4).VBS> (Line: 9, Column: 1):
    File name or class name not found during Automation operation: 'CreateObject'
    I have googled through the error and tried to re-register the scrrun.dll using regsvr32 eventhogh it is successfully registered, i am getting the following error. My PC is windows 7 32bit OS.
    any help is greatly appreciated.

    The following script class will write a log file entry. See if it will run for you.
    The script is using a class object that you might not have seen before. A little intro:  The top section is just for testing the class. Normally I just comment this out after the class is working well.  It should run right way. I would save the vbs file in the editor, That way when you are using autoactpath or currentscriptpath variables they will be able resolve the paths.
    Paul
    Attachments:
    LoggingCode_V2.VBS ‏5 KB

  • Can't find "Delegate Class Name" for JDBC Helper Service

    Hi,
    I downloaded WLServer 6.1 with sp1 and WLPortal 4.0, installed them on Solaris 7 using default DB cloudscape -- everything was fine. Now, I'm trying to configure database to Oracle 8.1.7.
    In "Configure the JDBC Helper Service" section of document "Configuring WebLogic Portal for Oracle Databases" (http://e-docs.bea.com/wlp/docs40/deploygd/oraclnew.htm), step 2 requires to enter value of "com.bea.p13n.util.jdbc.internal.OracleJDriverJdbcHelperDelegate" to "Delegate Class Name". But, I can't find this "Delegate Class Name" variable. The available varialbles on the Configuration tab on my screen are: Maximum Number of Retries, Maximum Wait Time (milliseconds), Use CLOBs for Read?, Use CLOBs for Write?. And the Configuration tab is the only available tag for JDBC Helper Service. Did I download a different version from other people? I downloaded it within 3 months.
    Can anyone help?
    Thanks in advance,
    Jane

    Thanks Steve.
    I had my own jndi.properties file that's why it was working with ejb bean I created in the AM and not with the sdo web service.
    I didn't know I had to add the jndi properties to the connection.xml maybe you can update the documentation.
    <?xml version = '1.0' encoding = 'UTF-8'?>
    <ns2:References xmlns:ns2="http://xmlns.oracle.com/adf/jndi">
    <Reference className="oracle.jbo.client.svc.Service"
    name="{/test/model/common/}DepartmentModuleService">
    <Factory className="oracle.jbo.client.svc.ServiceFactory"/>
    <RefAddresses>
    <StringRefAddr addrType="serviceInterfaceName">
    <Contents>test.model.common.serviceinterface.DepartmentModuleService</Contents>
    </StringRefAddr>
    <StringRefAddr addrType="serviceEndpointProvider">
    <Contents>ADFBC</Contents>
    </StringRefAddr>
    <StringRefAddr addrType="jndiName">
    <Contents>test.model.common.DepartmentModuleServiceBean</Contents>
    </StringRefAddr>
    <StringRefAddr addrType="serviceSchemaName">
    <Contents>DepartmentModuleService.xsd</Contents>
    </StringRefAddr>
    <StringRefAddr addrType="serviceSchemaLocation">
    <Contents>test/model/common/serviceinterface/</Contents>
    </StringRefAddr>
    <StringRefAddr addrType="jndiFactoryInitial">
    <Contents>oracle.j2ee.rmi.RMIInitialContextFactory</Contents>
    </StringRefAddr>
    <StringRefAddr addrType="jndiProviderURL">
    <Contents>ormi://localhost:23791/SvcInterfaceDeploy_MiddleTier</Contents>
    </StringRefAddr>
    <StringRefAddr addrType="jndiSecurityPrincipal">
    <Contents>fmwadmin</Contents>
    </StringRefAddr>
    <StringRefAddr addrType="jndiSecurityCredentials">
    <Contents>welcome</Contents>
    </StringRefAddr>
    <StringRefAddr addrType="serviceSchemaName">
    <Contents>HRAppService.xsd</Contents>
    </StringRefAddr>
    </RefAddresses>
    </Reference>
    </ns2:References>
    thanks edwin

  • How to get the Class name of an API method?

    Like most of us, it's difficult to know where every method within a Java class is. Also, many of the same methods are scattered throughout Java Classes. I know of two methods that retreive this... getClass().getName(). But, you must have an object to use these. Is there a way to find out what Class contains a method or Class variable thru an Applet or Java Application?? Obviously, I can look at API Docs; but this takes time.
    Tks Randy

    RajEndiran wrote:
    Can anyone please let me know how we can get the class name of a page or region in oracle apex?What do you mean with class name? The name of the template (e.g. the css style class name)?
    I would also like to know how we get the DOM object ID for particular item.Use firebug or inspect the source code of the rendered page to see the object IDs. Other then then, the typical ID of page items is the name of the item. For regions you can set your own ID.

  • How to typecast an object, if the target class name is stored in a str var

    Hi,
    I have a method, in which i will receive an object as an attribute. I need to typecast it to another class, and that class name is stored in a string variable.
    public void printContent(Object obj)
    /* Here i have a variable strClassName - in which a class name is stored.
    I need to create a variable for that class and type cast the object obj into that class. */
    Please kindly help me to find out a way to do this.
    Thanks in advance

    Typecasting does one thing: it enables you to store an object in a reference variable of the target type (if it is of a type which is allowed to be in that variable). It doesn't alter the object in any way.
    Therefore it simply isn't meaningful to talk about typecasting to a type name known only at run time. The whole point of typecasting is to tell the compiler to treat a reference as being of a specified type.
    I don't know what you're trying to do but I think you should probably be looking at the reflection api, getting field an method information from the object's Class object.

  • Class.forName() doesn't take dynamic class name

    String name="";
    String country="";
    String className = name + "_" + language + "_" + country;
    Class thisClass = Dynamicclassload.classLoad(className);
    System.out.println(className);
    Class class1 = Class.forName(className);
    child = (ResourceBundle) class1.newInstance();
    child.setParent( bundle );
    bundle = child;
    System.out.println("I am here");
    As i am passing classname as variable it throws an exception class not found exception.but if we write class name as the parameter of class.forName().it works.i am implementing in j2me
    why this happen? give me solution.

    The following classpackage test;
    public class TestLoad {
        String aString = "This is a Test";
        Integer anInteger = new Integer(42);
        public TestLoad() {
            System.out.println("aString = " + aString + ", anInteger = " + anInteger);
    }works correctly when loaded and instantiated by this class:package test;
    import java.util.logging.Logger;
    public class ExecuteTest {
        public static final Logger log = Logger.getAnonymousLogger();
        public static void main(String[] args) {
            try {
                Class clazz = Class.forName("test.TestLoad");
                TestLoad test = (TestLoad) clazz.newInstance();
            } catch (Exception ex) {
                log.severe(ex.toString());
    }and produces the string "aString = This is a Test, anInteger = 42"
    I used the following version of Java on Windows 2000
    java version "1.4.0"
    Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-b92)
    Java HotSpot(TM) Client VM (build 1.4.0-b92, mixed mode)

  • Jsp's class name

    Sorry that i'm new here.
    I want to connect the jsp and the database.
    How can i do that?
    what is the config of the system variable?
    what is the class name to invoke the driver?
    I'm using Oracle 10g in Window XP.
    and tomcat as the web server.
    THX~experts~!!

    A JDBC connection may be used as a JNDI resource.
    If the Connections-Navigator connection is DBConnection1, the corresponding datasource is jdbc/DBConnection1DS.
    1. Create a JSP page.
    2. In the web.xml of the JSP add
    <resource-ref>
    <res-ref-name>jdbc/DBConnection1DS</res-ref-name>
    <res-type>javax.sql.DataSource</res-type>
    <res-auth>Container</res-auth>
    </resource-ref>
    3. In the JSP page obtain a connection with the datasource.
    InitialContext initialContext = new InitialContext();
    javax.sql.DataSource ds = (javax.sql.DataSource)initialContext.lookup("java:comp/env/jdbc/DBConnection1DS");
    java.sql.Connection conn = ds.getConnection();

Maybe you are looking for

  • Facebook, google ERROR sec_error_unknown_issuer in Fresh Firefox 35 windows 8.1

    Windows 8.1 64-bit Firefox 35 (Latest) - Fresh Installed firefox 35 - Even refreshed Firefox with safe-mode - when opening page google.com, facebook.com (Attached Image) getting error page that should not be the error/exception. - This is not for the

  • Filter bar not to be reset on folder change

    If I set up search criteria using the filter bar and then click on a different folder in the folder panel, the filter bar is reset. I would like to be able to control this behaviour so that the search criteria remain in place.

  • Deletion of DDIC Table with Maintaince View

    Hello, I try to delete a  table with existing maintance dialog. So first I deleted the generated objects in SE54. The corresponding funtion group is now no longer existing. When I now try to delete the table in SE11 I got the message that it is still

  • Getting relief on maps in aperture 3

    When one clicks on Places in Aperture 3 one can zoom in to see mountains, rivers, etc. If you choose a map for a page while building a book the maps are flat. Is there a way to get this relief view in a book map?

  • To assign logo to oracle form 10g

    i want to assign a logo to form 10g that is display at right corner at runtime. At runtime a word oracle is display at corner i want to replace a logo at the place of word oracle . how i can do it