Solved

Embedded Applet "dynaCounter" needed (pretty please)

Posted on 2002-04-13
4
280 Views
Last Modified: 2012-06-27
If you can write this .java file, that would be
wonderful! I am not a JAVA programmer, but I  think I will
be able to compile the code you write. I bet this assignment would not be too difficult for a
JAVA guru like yourself!

<HTML>
<BODY>
<CENTER>
<applet code="txt.class" name="dynaCounter" width=300 height=25>
</applet>
</CENTER>
</BODY>
</HTML>

JAVA APPLET TO START OUT TRANSPARENT (ALL WHITE),
BUT THEN, WHEN PASSED 2 INTEGERS FROM THE
 HTML DOCUMENT (using JavaScript),
THE APPLET WOULD REFRESH ITSELF AND DISPLAY A
TEXT STRING BASED ON THE VALUES PASSED (black text on white background).

When JavaScript passes two zeros to the applet,
it should go blank again (ALL WHITE).

THE HTML DOCUMENT WOULD PASS A NEW INTEGER VALUE PAIR
UP TO SEVERAL TIMES/SECOND, VIA JavaScript.
THE STRINGS TO BE DISPLAYED WOULD BE...

1st: "Searching article 1 of [y]"
2nd: "Searching article 2 of [y]"
3rd: "Searching article 3 of [y]"
etc.
last:"Searching article [y] of [y]"

[y] will never exceed 10,000, and the first value
passed will always be <= [y] (which may help you
to help pick the variable type).

The displayed text in the applet on the HTML page would
be right aligned, ideally.  There should be room for 34 characters
to display in the applet, minimum.

Thank to you all!
Tony
0
Comment
Question by:boatful
  • 2
4 Comments
 
LVL 9

Expert Comment

by:Ovi
ID: 6941382
Good luck !!! (Is time for you to learn some Java programming).
0
 

Accepted Solution

by:
megloff earned 200 total points
ID: 6943320
Hi...
The work wasn't easy... but I think I have solved more or less the most of it...was this your homework ? ; )

here

HTML File:

<HTML>
<HEAD>
   <TITLE>Applet HTML Page</TITLE>
</HEAD>
<BODY onload="document.MyApplet.setInt(0,10);">
<APPLET name='MyApplet' code="MyApplet.class" width=350 height=200></APPLET>
<Script language='javascript'>
    function funci()
    {
        document.MyApplet.repaint();
    }
    window.setInterval("funci()",1000);
</SCRIPT>

</BODY>
</HTML>

Java Applet:

import java.awt.*;

public class MyApplet extends java.applet.Applet {
     
int a = 0;
int b = 0;

public void init()
{
     this.setBackground( new Color(0xFF,0xFF,0xFF));
}

public void setInt(Number  a, Number b)
{
     this.a = a.intValue();
     this.b = b.intValue();
     repaint();
}

public void paint(Graphics g)
{
     if ( a== 0 && b == 0) g.setColor(new Color(0xFF,0xFF,0xFF));
     else g.setColor(new Color(0x0,0x0,0x0));
     if ( a < b ) a++;
     g.drawString("Searching article "+a +" of ["+b+"]",10,10);
}
}

0
 

Author Comment

by:boatful
ID: 6944452
This was not my homework.  I am webmaster for a paddling club, and I have 25 years of bi-annual newsletter back issues I am archiving.  They are searchable, which is a pretty cool think for someone whose files reside on the AOL server with no CGI-BIN.
I was able to implement a DHTML solution which works for MSIE4 and higher, but not netscape.  You can see it online at http://members.aol.com/boatful/bowstern/bowstern.htm

I want to give the points to megloff for being so willing to give this a try, though I haven't tested it yet.  It looks satisfactory, at first glance.  THANKS SO MUCH!  Maybe someday I can implement the applet dynacounter, so my netscape-equipped visitors can have the same functionality as MSIE4+.
0
 

Expert Comment

by:megloff
ID: 6945852
Thank you... if you have any further questions... please let me know...

regards
mark
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

For customizing the look of your lightweight component and making it look opaque like it was made of plastic.  This tip assumes your component to be of rectangular shape and completely opaque.   (CODE)
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
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 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.

863 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

22 Experts available now in Live!

Get 1:1 Help Now