?
Solved

Two progresses, with only one JProgressBar?

Posted on 2005-03-09
7
Medium Priority
?
729 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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

Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

Question has a verified solution.

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

An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
Suggested Courses
Course of the Month10 days, 21 hours left to enroll

770 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