Java Applet Problem
by "Rasika Wijayaratne" <rasika(at)boursedata.com.au>
|
| Date: |
Fri, 17 Nov 2000 18:04:43 +1100 |
| To: |
"HWG-Scripting" <hwg-languages(at)hwg.org> |
| |
todo: View
Thread,
Original
|
|
Hi
Below is my first applet. Im pretty new to Java but i understand the
fundamentals. The Applet (Progress.class) below compiles alright. But it
doesnt display properly in the browser. I know something is missing in the
source code which is causing this, can anyone throw some light on this? Its
a progress bar, similar to ones found on OSs, when the OS is doing something
it displays the progress if the action being performed (example when
searching fro a file or copying a file)...
<applet code="Progress.class" width="500" height="90">
<param name="strLevelIn" value="295">
</applet>
Sorry about the code offsetting, it has something to do with Outlook
Express...
===========
import java.awt.*;
import java.awt.event.*;
import java.awt.geom.*;
import javax.swing.*;
import java.net.*;
import java.applet.*;
public class Progress extends JApplet {
public void paint(Graphics g) {
Graphics2D g2 = (Graphics2D) g;
BasicStroke stroke = new BasicStroke(3.0f);
int x0 = 0;
int y0 = 25;
int height0 = 16;
int width0 = 492;
//black bar
g2.setPaint(Color.black);
g2.setStroke(stroke);
g2.fill(new Rectangle2D.Double(x0, y0, width0, height0));
//grey bar
int x1 = 2;
int y1 = 27;
int height1 = 12;
int width1 = 488;
g2.setPaint(Color.gray);
g2.setStroke(stroke);
g2.fill(new Rectangle2D.Double(x1, y1, width1, height1));
//red bar
String levelIn = getParameter("strLevelIn");
int level = Integer.parseInt(levelIn);
int x = 2;
int y = 27;
int height = 12;
int width = level;
g2.setPaint(Color.red);
g2.setStroke(stroke);
g2.fill(new Rectangle2D.Double(x, y, width, height));
//text labels
g2.setPaint(Color.black);
g2.drawString("Negotiation", 0, 20);
g2.drawString("Contract", 85, 20);
g2.drawString("Development", 150, 20);
g2.drawString("Invoicing", 250, 20);
g2.drawString("Testing", 340, 20);
g2.drawString("QA", 415, 20);
g2.drawString("Live", 470, 20);
}
}
HWG: hwg-languages mailing list archives,
maintained by Webmasters @ IWA
This page is part of a preserved archive of archives.hwg.org. The site is no longer active and its content is not maintained. For enquiries about this archive, write to archive(at)iwanet.org.