?
Solved

Embedded Applet "dynaCounter" needed (pretty please)

Posted on 2002-04-13
4
Medium Priority
?
305 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
[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
  • 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 800 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

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

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

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 …
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
This video teaches viewers about errors in exception handling.
Suggested Courses
Course of the Month9 days, 21 hours left to enroll

762 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