• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to invoke a private class after clicking the button that work?

 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 495
Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What exactly didn't work? Did you receive an error? If you did, please post it. What results were you expecting?

John Price
 
Ket Nonting
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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:

 
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


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
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic