Solved

Dealing with custom objects from the main applet class

Posted on 1998-04-13
1
217 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 50 total points
ID: 1234086
instead of using the getImage on My Button..  call this function instead.

Toolkit.getDefaultToolkit().getImage(myurl);


 
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
hibernate example using maven 12 80
eclipse console opening separately 2 38
Java basic valueOf question 1 34
Java array 10 63
Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
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…
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 will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

733 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