| Author |
How to invoke a private class after clicking the button that work?
|
Ket Nonting
Greenhorn
Joined: Aug 09, 2011
Posts: 20
|
|
Hi guys,
I have an applet with the following structure:
The question is how do I invoke the CoolStuff class that real works. It just compiled and did not work. I can't find any tutorial on the web about this.
And another question, can I invoke a java code snippet to run inside the CoolStuffs class.
Thanks in advance.
|
 |
john price
Ranch Hand
Joined: Feb 24, 2011
Posts: 495
|
|
What exactly didn't work? Did you receive an error? If you did, please post it. What results were you expecting?
John Price
|
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” (Mosher's Law of Software Engineering)
“If debugging is the process of removing bugs, then programming must be the process of putting them in.” (Edsger Dijkstra)
|
 |
Ket Nonting
Greenhorn
Joined: Aug 09, 2011
Posts: 20
|
|
Sorry for it's taking so long to reply. It's kind of bit embarrassment. I'm new to java and didn't know if people have done this and I'm a laggard.
I'm trying to capture a screenshot with java applet but it didn't seem to work. I can't invoke the subclass set of java application to automate.
Bellow is my experimenting so far, would be greatly appreciated if you can point out where it went wrong:
|
 |
Paul Clapham
Bartender
Joined: Oct 14, 2005
Posts: 13842
|
|
First of all, your comment is incorrect in that fragment from your post. You don't "invoke" a class in Java (except in that uncommon situation where you're running a class from the command line). What your code does is to create an instance of that class, nothing else. You apparently thought that "invoking" a class would call a method which happened to called "main". That's not the case either. If you want that method to be called, you're going to have to call it.
Although I wouldn't call it "main", that doesn't describe its function at all. I would call it "capture" or something like that. And I would get rid of the String-array parameter, since you don't use that anywhere in the method.
|
 |
Ket Nonting
Greenhorn
Joined: Aug 09, 2011
Posts: 20
|
|
Thank Paul,
Your comment is complicated to me. I don't understand it right now, because I'm new to this java thing. But I would try to understand it. Maybe I should start with the "call" method you mentioned. The "invoke" word was just borrowed from Oracle's tutorial website. I don't really understand what does it mean right now.
|
 |
Paul Clapham
Bartender
Joined: Oct 14, 2005
Posts: 13842
|
|
|
New to Java? And you're writing an applet? I don't recommend that, you're going to get into all kinds of non-Java complexities if you do that. Start off by writing a plain old Java application first.
|
 |
Ket Nonting
Greenhorn
Joined: Aug 09, 2011
Posts: 20
|
|
|
Thanks for suggestions. I've learned basic java programing. But the application didn't serve my purpose. I jump to an applet thing. That is very helpful suggestion. I will do this.
|
 |
 |
|
|
subject: How to invoke a private class after clicking the button that work?
|
|
|