Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Dealing with custom objects from the main applet class

Posted on 1998-04-13
1
Medium Priority
?
221 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 1

Accepted Solution

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

Toolkit.getDefaultToolkit().getImage(myurl);


 
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
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.
Suggested Courses

636 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