Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Two progresses, with only one JProgressBar?

Posted on 2005-03-09
7
Medium Priority
?
732 Views
Last Modified: 2010-03-31
Hey,

Anyone know how to achieve an effect like the one here: http://java.sun.com/products/jfc/tsc/sightings/S01/swarmcast/swarmgate-gui.jpg
Where there are two progresses, with only one JProgressBar?

I'm hoping that I don't need to draw my own custom Progress Bar..?

Any examples would be fab! ^_^

Thanks in advance,
>> IM
0
Comment
Question by:InteractiveMind
  • 2
  • 2
  • 2
  • +1
7 Comments
 
LVL 37

Assisted Solution

by:zzynx
zzynx earned 200 total points
ID: 13498196
>> I'm hoping that I don't need to draw my own custom Progress Bar..?
I think you'll need
0
 
LVL 5

Assisted Solution

by:Naeemg
Naeemg earned 200 total points
ID: 13498255
I think you should use two progress bars for ur two different events.
because in your example , one is overlapping over other.
and if back bar has minor value than front bar then how user can determine that back progress is moving at which point.

as I think there is now builtin prograss bar u desired.
you may use two progressbars parellel. and it will be easy for user to analyze the work progress of both events.
0
 
LVL 5

Expert Comment

by:Naeemg
ID: 13498267
or you may use BAR CHART for such purposes. as they provides such functionality.
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 6

Accepted Solution

by:
durgaprasad_j earned 1600 total points
ID: 13498274
Hi,
I doubt has he used JProgressBar ?
IMO, he has used normal JLabel and manually painted that.
In any case, he has to use customPainting.

If you want to use JLabel to achieve same thing, you can do some thing like this.

JLabel jl=new JLabel()
{
         public void paintComponent(Graphics g)
         {
                  g.fillRect( ...... ) //some part with yellow
                  g.fillRect(.......) //some part with red
         }
};
jl.setPreferredSize(.....)      //set the size you want.

Hope this helps
0
 
LVL 25

Author Comment

by:InteractiveMind
ID: 13498882
Thanks very much all.
I've implemented durgaprasad_j's code into it.. and it looks pretty neat. I just need to develop a little 'engine' to automate the progress animation...

For people of the future, searching the knowledge base, and who come across this; then here's an example of a 'still' progress bar with multiple progresses -- it's just a case of animating it yourself:


//====8<----[ Test.java ]----
import java.io.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.border.*;

public class Test extends JFrame
{
      
      public Test ()
      {
            super("Progress Test");
            setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            setSize( 200, 70 );
            
            JPanel pane = new JPanel();
            setContentPane(pane);
            
            JLabel jl = new JLabel()
            {
                  public void paintComponent(Graphics g)
                  {
                        g.setColor(Color.RED);
                        g.fillRect(0,0,100,20);
                        g.setColor(Color.BLUE);
                        g.fillRect(0,0,75, 20);
                        g.setColor(Color.WHITE);
                        g.fillRect(100,0,100, 20);
                  }
            };
            jl.setPreferredSize( new Dimension( 200, 20) );
            Border bord = BorderFactory.createLineBorder(Color.BLACK);
            jl.setBorder(bord);
            
            pane.add(jl);
            
            setVisible(true);
      }
      
      public static void main ( String [] args )
      {
            new Test();
      }
      
}
//====8<----[ Test.java ]----


Thanks very much all three of you -- most points will be going to durgaprasad_j  ^_^

>> IM
0
 
LVL 6

Expert Comment

by:durgaprasad_j
ID: 13498942
Thanks man :)
0
 
LVL 37

Expert Comment

by:zzynx
ID: 13503716
thanks
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
Suggested Courses
Course of the Month11 days, 19 hours left to enroll

564 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question