Solved

Dealing with custom objects from the main applet class

Posted on 1998-04-13
1
213 Views
Last Modified: 2010-04-16
Hi all. Here's my question I hope you analyze and answer :)

I have the main class which is a subclass of Applet of course. My problem is that I cannot create my own classes and use the object of those classes in the main class. For example, suppose I have the main class called MyApplet. The dimensions are (0, 0, 200, 100). This is what I'm trying to program. A rectangle drawn around all the edges of the applet (as a frame of the applet window). The background of the window must be white. And in that frame, I want to place some custom buttons, which are formed by a gif and a yellow text at the center of it. This is what I've thought about a possible implementation:

Create the main class this way: public class MyApplet extends Applet. Other class that extends Canvas this way: public class MyFrame extends Canvas. And the last that extends nothing, this way: public class MyButton.
Is right this approach? Can you recommend me other easier implementation? I tried this, but I don't know why computer crashed when MyFrame object was created.

My purpose is to encapsulate a button so I can place it wherever I want in the applet window. But to accomplish that, I need to use getImage from the MyButton class to load the background image of the button, but that function is actually returning "null". Don't know why.

I hope you, experts, help me in this problem. Thanks in advance
Skel
0
Comment
Question by:skel
1 Comment
 
LVL 1

Accepted Solution

by:
bogamo earned 50 total points
ID: 1234086
instead of using the getImage on My Button..  call this function instead.

Toolkit.getDefaultToolkit().getImage(myurl);


 
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

929 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now