Solved

Applet difficulty

Posted on 1997-03-11
1
300 Views
Last Modified: 2012-05-04
I am having difficulty with applets I am using. Both of the applets I wish to use require more than one ".class" file, but there doesn't seem to be anywhere where the first calls the second or refers to the second. eg an applet which is supposed to allow the user to change text color and bgcolor but does not, a default color seems to always come up. Looking at the code, the class file which has reference to bgcolor etc is in "thoughts.class", actual paraname values which can be changed are in a separate class file. Both class files are in the same directory but the bgcolor and text color values do not change to the required input. The same happens with the LivingLinks.class. There is a Fade.class plugin for this applet, but I am unable to  get it to work.
Any suggestions would be appreciated.

Thanks,  Craig
0
Comment
Question by:craigo
[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:
tatti earned 100 total points
ID: 1218990
Let's see if I understood this correctly. You have an applet that consists of multiple classes. The applet class receives color information from applet parameters, or where ever.

The problem is that you have another class which draws stuff on the applet and it should get to know the colors to use. You can either make the colors class or instance variables (static or normal).

If you make them static, you can refer to them from the other class as "AppletClass.FOREGROUNDCOLOR". If they are normal instance variables, you will need to tell the other class's instance where the applet instance is located. Here's a dummy example of the latter:

import java.applet.Applet;
import java.awt.*;

class Test extends Applet {
  Color fore,back;
  Inner in;
  public void init() {
    in=new Inner(this);
  }
  public void paint(Graphics g) {
    in.paint(g);
  }
}

class Inner {
  Test myowner;
  public Inner(Test owner) {
    myowner=owner;
  }
  public void paint(Graphics g) {
    g.setColor(myowner.fore);
    g.drawString("Greetings from Inner class",10,10);
  }
}

0

Featured Post

Want Experts Exchange at your fingertips?

With Experts Exchange’s latest app release, you can now experience our most recent features, updates, and the same community interface while on-the-go. Download our latest app release at the Android or Apple stores today!

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…
In this post we will learn different types of Android Layout and some basics of an Android App.
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
This video teaches viewers about errors in exception handling.

615 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