|
-
Jun 28th, 2002, 01:58 PM
#1
Thread Starter
Hyperactive Member
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.
-
Jun 28th, 2002, 02:43 PM
#2
Dazed Member
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;
-
Jun 28th, 2002, 02:48 PM
#3
Dazed Member
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.
-
Jun 29th, 2002, 06:31 AM
#4
Thread Starter
Hyperactive Member
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.
-
Jun 29th, 2002, 12:40 PM
#5
you need to add package 3rdclass; in the imported class
-
Jun 29th, 2002, 04:42 PM
#6
Dazed Member
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?
-
Jun 30th, 2002, 08:57 AM
#7
Thread Starter
Hyperactive Member
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.
-
Jun 30th, 2002, 01:39 PM
#8
Dazed Member
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.
-
Jun 30th, 2002, 04:34 PM
#9
Thread Starter
Hyperactive Member
[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...
-
Jun 30th, 2002, 04:45 PM
#10
Dazed Member
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|