Total members 10261 | Gratitudes |It is currently Tue May 22, 2012 5:21 pm Login / Join Codemiles


All times are UTC [ DST ]




Post new topic Reply to topic  Quick reply  [ 1 post ] 
Author Code Snippet
 Code subject: Progress dialog
PostPosted: Sat Nov 27, 2010 11:32 pm 
Offline
Mastermind
User avatar

Joined: Tue Mar 27, 2007 10:55 pm
Posts: 2279
Location: Earth
Has thanked: 39 time
Have thanks: 61 time

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);
    }
}
 

_________________
Currenlty programming with : java , html , php , and javascript . (OCJP-6 certified )


TOP
 Profile Send private message  
Reply with quote  
Post new topic Reply to topic Quick reply  [ 1 post ] 
Quick reply


  

 Similar topics
 status Progress bar
 Multipart HTTP forms submitter - With Progress Information
 java confirmation dialog

All times are UTC [ DST ]


Users browsing similar codes

Users browsing this forum: No registered users and 1 guest



Jump to:  
Previous Code Snippet | Next Code Snippet 




Home
General Talks
Finished Projects
Code Library
Games
Tutorials

Java
C/C++
C-sharp
php
Script
JSP/Servlets
Ajax
ASP/ASP.net
Google SEO
Database
Communications
Phpbb3 styles
Photoshop tutorials
Flash tutorials
Find a job






Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2011
mileX v1.0 designed by codemiles team