JProgressBar .... need assistance please..

Discussion in 'Java' started by Russell, Oct 17, 2004.

  1. Russell

    Russell Guest

    I'm playing with the idea of showing a JProgressBar in a small App' I trying
    to make.
    I want to display the progress of an array being populated....however I cant
    seem to get the bar to show the actual % state before it reaches 100%
    Am I missing something out?
    Please help me if you can..

    Thanks...

    #######################
    CODE BELOW
    #######################

    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;

    public class ArrayRandom extends JFrame {
    protected final int size = 100000;
    protected int[] prodRandm = new int[size];
    protected int min = 0;
    protected int max = 100;
    protected JProgressBar progress;
    protected JButton start;

    public ArrayRandom() {
    setSize(300,50);
    progress = new JProgressBar();
    progress.setStringPainted(false);
    progress.setIndeterminate(true);

    start = new JButton("Start");
    ActionListener act = new ActionListener() {
    public void actionPerformed(ActionEvent e) {
    progress.setMinimum(min);
    progress.setMaximum(max);
    progress.setIndeterminate(false);
    progress.setStringPainted(true);
    for (int i = 0; i < size; i++) {
    prodRandm = i;
    progress.setValue((i/1000)+1);
    progress.setString((i/1000)+1+" %");
    }
    }
    };
    start.addActionListener(act);
    getContentPane().setLayout(new BorderLayout(10,10));
    getContentPane().add(progress, BorderLayout.CENTER);
    getContentPane().add(start, BorderLayout.WEST);
    }

    public static void main(String[] args) {
    ArrayRandom frame = new ArrayRandom();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setVisible(true);
    }
    }
     
    Russell, Oct 17, 2004
    #1
    1. Advertising

  2. Russell

    Alex Hunsley Guest

    Russell wrote:
    > I'm playing with the idea of showing a JProgressBar in a small App' I trying
    > to make.
    > I want to display the progress of an array being populated....however I cant
    > seem to get the bar to show the actual % state before it reaches 100%
    > Am I missing something out?
    > Please help me if you can..
    >
    > Thanks...
    >


    Russell, please don't multipost (there is never any good reason to).

    http://www.blakjak.demon.co.uk/mul_crss.htm

    You question is much more suited to comp.lang.java.help, where I have
    answered it. In future it would be good to restrict similar questions to
    that newsgroup.

    alex
     
    Alex Hunsley, Oct 17, 2004
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Cengiz

    Update of JProgressBar

    Cengiz, Aug 6, 2003, in forum: Java
    Replies:
    2
    Views:
    904
    Cengiz
    Aug 7, 2003
  2. Inertia_sublimation
    Replies:
    5
    Views:
    2,126
    Inertia_sublimation
    Jan 3, 2004
  3. FET

    JProgressbar look n feel

    FET, Jul 22, 2004, in forum: Java
    Replies:
    3
    Views:
    1,530
  4. C.Steamer

    Problems with JProgressBar!!!

    C.Steamer, Sep 22, 2004, in forum: Java
    Replies:
    2
    Views:
    1,089
    ***C.Steamer***
    Sep 22, 2004
  5. =?Utf-8?B?Q2hyaXM=?=

    I need your assistance please

    =?Utf-8?B?Q2hyaXM=?=, Sep 4, 2007, in forum: ASP .Net
    Replies:
    2
    Views:
    398
    =?Utf-8?B?Q2hyaXM=?=
    Sep 5, 2007
Loading...

Share This Page