Hi, I want to add progress bar in my programme for showing the status of uploading of file.Can any one plz give me the code for that.I tried like that but couldn't slove my problem.Below r my codes:- import java.awt.*; import java.awt.event.*; import javax.swing.event.*; import java.util.*; import javax.swing.*; import java.io.*; import java.net.*;
public class ActionDemo4 extends JFrame implements ActionListener { public JTextArea textArea; public JProgressBar progressBar; public Timer activityMonitor; public SimulatedActivity activity; public JButton Button; URL url; URLConnection urlConn; DataOutputStream printout; public ActionDemo4() { setTitle("Upload Interface"); addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } });
int k=(int)l/1000; progressBar.setMaximum(k); activity=new SimulatedActivity(k); activity.start(); activityMonitor.start(); Button.setEnabled(false);
textArea.append("\n"+"Your Selected File Name is "+aa); textArea.append("\n"+"File Size Is "+l+"bytes"); textArea.append("\n"+ "Please Wait ! Upload Is in Progress"); //textArea.append("\n"+str2);
} public void actionPerformed(ActionEvent e) { textArea.setText(e.getActionCommand()); } public static void main(String[] args) { ActionDemo4 frame = new ActionDemo4(); frame.pack(); frame.setSize(new Dimension(650, 400)); frame.setLocation(100,100); frame.setVisible(true); } } class SimulatedActivity extends Thread { public SimulatedActivity(int t) { current=0; target=t; } public int getTarget() { return target; } public int getCurrent() { return current; } public void run() { while(current<target && !interrupted())> { try { sleep(10); } catch(InterruptedException e) { return; } current++; } } private int current; private int target; } I want to add my uploading programme in run method of SimulatedActivity class.Iam new to swing. Plz help me. Thanks for ur valuable Time Bikash ------------------
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.