Solved

Embedded Applet "dynaCounter" needed (pretty please)

Posted on 2002-04-13
4
268 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
Comment Utility
Good luck !!! (Is time for you to learn some Java programming).
0
 

Accepted Solution

by:
megloff earned 200 total points
Comment Utility
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
Comment Utility
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
Comment Utility
Thank you... if you have any further questions... please let me know...

regards
mark
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

For customizing the look of your lightweight component and making it look lucid like it was made of glass. Or: how to make your component more Apple-ish ;) This tip assumes your component to be of rectangular shape and completely opaque. (COD…
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…
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 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:

743 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

16 Experts available now in Live!

Get 1:1 Help Now