Hi nanba (Dear viewer)................
............whether you have noticed the progress bar while copying/downloading the file...... I started dreaming a while about the effort behind the bar which increase our eagerness towards the file wen it ill reach other end of the bar in completion of the download.
Below screen is my thoughts on progress bar.
Below is the small level of impl with help of four letter magic word 'java' Im sorry for legend viewers for my poor coding standard
Awaiting for ur valuable rplies to brighten my path towards my goal...... Thanks in advance
Progress.java
######################################
import java.awt.*;
import java.applet.*;
import java.awt.event.*;
import java.lang.Thread;
/*
<applet code="Progress" width=300 height=300>
<param name="img" value="ggg.jpg">
</applet>
*/
public class Progress extends Applet implements ActionListener {
Button com;
TextField in;
String mess="";
String num = "";
float n,s;
String msg1= "Progress Status";
int i=1;
public void init() {
setLayout(new FlowLayout(FlowLayout.LEFT));
com = new Button("START");
Label estimate = new Label("Estimated Memory: ", Label.RIGHT);
in= new TextField(5);
add(estimate);
add(in);
add(com);
in.addActionListener(this);
com.addActionListener(this);
}
public void actionPerformed(ActionEvent ae) {
try
{
num=in.getText();
repaint();
}
catch(Exception e){}
}
public void paint(Graphics g)
{
int per=0;
int len=0;
int adj=0;
String p = "";
String pernew= "";
try{
g.drawRect(50,50,200,20);
int n= Integer.parseInt(num);
while(i<=n)
{
per=((i*100)/n);
pernew=String.format("%10d%n",per);
g.setColor(Color.WHITE);
g.fillRect(150,150,230,230);
g.setColor(Color.BLACK);
g.drawString(msg1+""+pernew+"%",150,230);
System.out.println("i valuae:"+i);
System.out.println("Percentage completed"+per);
len=((per*150)/100);
adj=len+50;
g.setColor(Color.RED);
g.fillRect(50,50,adj,20);
Thread.sleep(1000);
i++;
}
if(i>n){
g.setColor(Color.BLACK);
g.drawRect(80,80,200,50);
mess="Process Completed";
g.drawString(mess,100,100);
}
}
catch(Exception e) {}
}
}