Solved

Embedded Applet "dynaCounter" needed (pretty please)

Posted on 2002-04-13
4
297 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: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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
fibonacci ten numbers 4 54
Java string replace 11 61
how to debug htl and js pages 8 53
ejb message driven bean mdb creation steps 2 34
An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
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:

685 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