?
Solved

Dealing with custom objects from the main applet class

Posted on 1998-04-13
1
Medium Priority
?
219 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

Get real performance insights from real users

Key features:
- Total Pages Views and Load times
- Top Pages Viewed and Load Times
- Real Time Site Page Build Performance
- Users’ Browser and Platform Performance
- Geographic User Breakdown
- And more

Question has a verified solution.

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

By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
Suggested Courses
Course of the Month11 days, 5 hours left to enroll

770 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