Solved

Embedded Applet "dynaCounter" needed (pretty please)

Posted on 2002-04-13
4
294 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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

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…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

856 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