Results 1 to 10 of 10

Thread: An applet into an applet...

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jan 2002
    Location
    Palermo, Italy
    Posts
    325

    Question An applet into an applet...

    How can I use 3rd part applet into my own applet??!?
    Is this statement correct??!?

    Code:
    import java.applet.*;
    import java.awt.*;
    import 3rdPartApplet;
    
    ...
    ...
    public class MyOwnApplet extends Applet
    {
    
    	public void paint (Graphics g)
    	{
    		g.drawString("Hello",0,50);
    	}
    
    }
    But how can I use the methods defined into 3rdPartApplet??!?


    Thx in advance...
    Xmas.

  2. #2
    Dazed Member
    Join Date
    Oct 1999
    Location
    Ridgefield Park, NJ
    Posts
    3,418
    Since you already defined the package that the types reside in i guess you would just have to create a new instance of whatever class you want to use that is in the 3rdPartApplet namespace and then just invoke the desired method.

    The import statement is correct if you have it like this
    Code:
    import 3rdPartApplet.*;
    or
    Code:
    import 3rdPartApplet.classwhishingtobecreated;

  3. #3
    Dazed Member
    Join Date
    Oct 1999
    Location
    Ridgefield Park, NJ
    Posts
    3,418
    One more thing. Lets say i have java.util; even though i know and you know that util is just a namespace the compiler will yell at you because it thinks that you are specifing a class. So the name space must either end with a .* or a class name.

  4. #4

    Thread Starter
    Hyperactive Member
    Join Date
    Jan 2002
    Location
    Palermo, Italy
    Posts
    325
    Ok, one more thing.

    I have Visual J++ 1.1
    It's all ok, even without ".*". I can use all methods, but I can't figure out how to connect to a server and exchange data with it.
    I tried code snippets taken form all internet but couldn't get it to work.


    I downloaded Java 2 1.4 from Sun.
    It says "Error: needed .* after 3rdclass"
    So I added .*
    But now it says "Error: package 3rdclass doesn't exist".

    How can I solve the first problem? Or how can I solve the second?

    Thx
    Xmas.

  5. #5
    DaoK
    Guest
    you need to add package 3rdclass; in the imported class

  6. #6
    Dazed Member
    Join Date
    Oct 1999
    Location
    Ridgefield Park, NJ
    Posts
    3,418
    As for any database stuff pertaining to Java in i couldn't help you. I usually use VB as a front end for SQL Server. But as for your second question. The compiler warning saying "Error: needed .* after 3rdclass" would be correct since 3rdclass is a package and you would have to use the .* to be able to refrence all of the classes contained within the namespace or you would just have to specify the class in the import directive (without the .*) that you are trying to refrence.


    Also,did you define the package directive at the very top of all of your class files that are contined in the 3rdclass directory?

  7. #7

    Thread Starter
    Hyperactive Member
    Join Date
    Jan 2002
    Location
    Palermo, Italy
    Posts
    325
    Uhm... I want to do a strange thing, let's explain.

    I found out how to make 3rdpartclass working in my project.
    It works with Microsoft Visual J++ 1.1 with the directive
    Code:
    import 3rdclassname;
    Now I found out how to connect to a server with Java 2 from Sun(with j++ I can't). But the thing I can't figure out is create a class with Java 2 Sun and use with J++.
    Here's the schematical code...

    MyProj:

    Code:
    import 3rdclass;
    import MyConnClass;
    .
    3rdclassobj obj=new 3rdclassobj();  //Use it...
    .
    MyConnClass obj2=new MyConnClass(); // Here's error: "Unhandled exception in MyProj: 0x00000000 Java Exception"
    This is a null pointer error I think... Why??!?

    MyConnClass:
    Code:
    public class MyConnClass
    {
        MyConnClass()
            {};
    }
    Even with a null class I can't do it...

    I don't know if there's package statement into 3rdclasspart because I didn't write it... It's 3rdclasspart...

    What I can do?!?

    Pls Help...

    Xmas.

  8. #8
    Dazed Member
    Join Date
    Oct 1999
    Location
    Ridgefield Park, NJ
    Posts
    3,418
    The error message that you are getting is because you have to wrap any code that you want error handling to occur with a try{} block.

  9. #9

    Thread Starter
    Hyperactive Member
    Join Date
    Jan 2002
    Location
    Palermo, Italy
    Posts
    325

    Cool [RESOLVED] An applet into an applet...

    No, no.... I finally understood why... It was a compiler directive... I recompiled MyConnClass with this line:
    Code:
    javac -target 1.1 MyConnClass
    Now all works fine...

  10. #10

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width