Solved

Dealing with custom objects from the main applet class

Posted on 1998-04-13
1
212 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
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…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

758 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

17 Experts available now in Live!

Get 1:1 Help Now