Total members 11889 |It is currently Fri Mar 29, 2024 3:21 am Login / Join Codemiles

Java

C/C++

PHP

C#

HTML

CSS

ASP

Javascript

JQuery

AJAX

XSD

Python

Matlab

R Scripts

Weka





Following example show you how to create a dialog which contains , progress bar .Please take in mind that while your are waiting other processes is to use threads. For example you may want to run the main application process in a thread and the updating of the progress bar in other thread.

Code:

import java
.awt.BorderLayout;
import java.awt.Point;
import javax.swing.BorderFactory;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JProgressBar;
import javax.swing.border.Border;

public class 
ProgressDialog extends JDialog {

    private final 
JPanel panel = new JPanel();
    private 
JProgressBar jProgressBar;
    private 
JLabel jLabel;

    public 
ProgressDialog(JFrame frameint initialString statusDescription) {
        
setTitle("Progress Dialog.");
        
jProgressBar = new JProgressBar();
        
jProgressBar.setString("In Progress ");
 

        
jProgressBar.setValue(25);
        
jProgressBar.setStringPainted(true);
        
Border border BorderFactory.createTitledBorder("Reading...");
        
jProgressBar.setBorder(border);

        
Point point frame.getLocation();
        
panel.add(jProgressBarBorderLayout.NORTH);
        
jLabel = new JLabel(statusDescription);
        
panel.add(jLabel);
        
add(panel);
         
        
setResizable(false);
        
setAlwaysOnTop(true);
        
setSize(300300);
        
setLocation((int) point.getX() + 100, (int) point.getY() + 100);

    }

    public 
void setPercentage(int percent) {
        
jProgressBar.setValue(percent);
    }
}
 




_________________
M. S. Rakha, Ph.D.
Queen's University
Canada


Author:
Mastermind
User avatar Posts: 2715
Have thanks: 74 time
Post new topic Reply to topic  [ 1 post ] 

  Related Posts  to : Progress dialog
 java confirmation dialog     -  
 Show popup dialog using JQuery     -  
 status Progress bar     -  
 Show Progress Bar using JQuery     -  
 Multipart HTTP forms submitter - With Progress Information     -  



Topic Tags

Java Swing






Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2011
mileX v1.0 designed by codemiles team
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com