Web Design and Development Forums

Help need with 2 progress bars

This is a discussion on "Help need with 2 progress bars" within the Java, JSP, Cold Fusion section. This forum, and the thread "Help need with 2 progress bars are both part of the Program Your Website category.


Go Back   Webforumz.com > Program Your Website > Java, JSP, Cold Fusion

Welcome to Webforumz.com.
Register Now Register now!

Reply
 
LinkBack Thread Tools Rate Thread
Old Apr 20th, 2007, 22:59   #1 (permalink)
 
AdRock's Avatar
 
Join Date: Jul 2006
Location: Devon, England
Posts: 567
Send a message via MSN to AdRock
Help need with 2 progress bars

I need to make an applet that has 2 progress bars.

The top progress bar needs to move twice as fast as the bottom progress bar.

I have got the top progress bar to work but no matter what I try, I can't get the second progress bar to move slower than the first one. I can get them to move at the same time which is no good.

Does anyone know how I can do this? I did try using a nested loop but I think I messed it up. Any help would be very much appreciated.

I know this code isn't perfect but it's the only example that i was able to work from.
Code: Select all
 
import java.awt.*;
import java.awt.event.*;
import java.applet.Applet;
public class Progress1 extends Applet implements Runnable
{   
 Thread runner;
 myCanvas ca = new myCanvas();
 Choice ch = new Choice();
 Label la;
 Button a;
 TextField tf;
 
 int xpos;
 int BarHeight = 30;
 int TopBarWidth = 2;
 int BottomBarWidth = 1;
 
 public void init() 
 {
  setLayout(new GridBagLayout());
        GridBagConstraints c = new GridBagConstraints();
  ch.addItem("IEEE 802.11a");
  ch.addItem("IEEE 802.11b");
  ch.addItem("IEEE 802.11g");
  ch.addItem("IEEE 802.11n");
  ch.addItem("IHomeRF");
  c.gridx = 0;
        c.gridy = 0;
        add(ch, c);
  
  la = new Label("Enter amount of data (Mbits) to be transferred");
  c.gridwidth = 2;
  c.gridx = 1;
  c.gridy = 0;
  add(la, c);
  
  tf = new TextField("",12);
  c.gridwidth = 2;
  c.gridx = 1;
  c.gridy = 2;
  add(tf, c);
 
  a = new Button("Transfer");
  c.gridx = 3;
  c.gridy = 2;
  add(a, c);
  
  ca.setBackground(Color.white);
  ca.resize(400,150);
  c.gridwidth = 4;
  c.gridx = 0;
  c.gridy = 3;
  add(ca,c);
  
  start();
 }
 
 public void start() 
 {
  if(runner==null)
  {
   runner= new Thread(this);
   runner.start();
  }
  repaint();
 }
 
 public void run() 
 {
 }
 
 public class myCanvas extends Canvas 
 {
  public void paint(Graphics g) 
  {
   g.setColor(Color.black);
   g.drawString("Theoretical Transfer Speed",0,25);
   g.drawString("Realistic Transfer Speed",0,85);
   
      g.setColor(Color.red);   
      g.drawRect (0, 30, 370, 30);
      g.fillRect (1, 31, 369, 29);
      g.drawRect (0, 90, 370, 30);
      g.fillRect (1, 91, 369, 29);
      
      for(xpos=1; xpos<=369; xpos+=1) 
      {
       g.setColor(Color.green);
       g.fillRect(xpos-1,31,BottomBarWidth,BarHeight);
       g.fillRect(xpos,31,BottomBarWidth,BarHeight);
       
       g.setColor(Color.black);
    g.drawString("Theoretical Transfer Speed",0,25);
       g.drawRect (0, 30, 370, 30);
       g.drawString("Realistic Transfer Speed",0,85);
       g.drawRect (0, 90, 370, 30); 
       
       try 
       {
        Thread.sleep(100);
       }
       catch (InterruptedException e)
       { 
       }     
      }   
      
  }
 }
}
AdRock is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Reply

Tags
threads

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
indeterminate progress bar veerbala82 ASP.NET Forum 3 Mar 12th, 2008 02:41
Slider/Progress Bar JCote1985 Flash & Multimedia Forum 1 Aug 2nd, 2007 21:22
Progress Bar Help Aaron1988 Flash & Multimedia Forum 28 Oct 18th, 2006 14:50
how can i make a progress bar selphie08 Flash & Multimedia Forum 10 Sep 18th, 2006 03:08
ASPUpload Progress bar da_stimulator ASP Forum 1 Dec 14th, 2004 17:29



Latest Updates

All Points SEO Security Advisory - CHECK YOUR SITE NOW!

Creative Coding :: February 2008

Webforumz is sponsored by: WESH UK Web Hosting
All times are GMT. The time now is 16:20.

Sleep Study Scoring :: Free Bet :: Website Templates :: Online Betting :: Bookmakers :: Funny Quotes :: Internet Recruitment Software :: Microsoft CRM Experts :: Online Casino :: Decorated Christmas Trees :: Midwife Forums :: Football Betting :: Ecommerce Software :: Web Hosting :: Football Stats :: Dry Cleaning Collection :: xtreme wales - extreme clothing :: Apuestas :: Sharepoint Consultants :: Website Optimisation :: Office Clearance London :: Sharepoint Experts :: Sports Betting :: Casino :: Website Templates :: Web Design Development India :: Online Gambling

Powered by: vBulletin Version 3.7, Copyright ©2000 - 2008, Jelsoft Enterprises Limited.
© 2003-2008 Webforumz.com : All Rights Reserved
Search Engine Friendly URLs by vBSEO 3.2.0 RC6


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59