Foros del Web » Programación para mayores de 30 ;) » Java »

Implementacion de Una ProgressBar.

Estas en el tema de Implementacion de Una ProgressBar. en el foro de Java en Foros del Web. Hace algunos dias hice una pequeña aplicacion y a esta misma quiero agregarle una ventana splash una barra de progreso, he buscado muchisimo por la ...
  #1 (permalink)  
Antiguo 29/03/2010, 12:00
 
Fecha de Ingreso: septiembre-2009
Mensajes: 63
Antigüedad: 14 años, 7 meses
Puntos: 0
Implementacion de Una ProgressBar.

Hace algunos dias hice una pequeña aplicacion y a esta misma quiero agregarle una ventana splash una barra de progreso, he buscado muchisimo por la red y no encuentro algo que me ayude.

Encontre el siguiente articulo

http://javax0711.blogspot.com/2009/12/ventana-splash-con-netbeans.html

He hecho todos lo que ahi mencionan y por mas que intento no me sale.

Saludos y espero que me puedan ayudar.
  #2 (permalink)  
Antiguo 29/03/2010, 17:24
 
Fecha de Ingreso: septiembre-2009
Mensajes: 63
Antigüedad: 14 años, 7 meses
Puntos: 0
Respuesta: Implementacion de Una ProgressBar.

Ya logre insertar la barra de progreso en mi apliacion..

El codigo debe quedar asi (el de la ventana con la progressbar)

Código PHP:
package Splash;
import java.awt.Color;

/**
 *
 * @author Admin
 */
public class principal extends javax.swing.JFrame

    
{
        
HiloProgreso hilo;

    
/** Creates new form principal */
    
public principal() {
        
//Método por defecto
        
initComponents();
        
iniciarSplash();
        
//Creamos un objeto HiloProgreso al cual
        //le pasamos por parámetro la barra de progreso
        
hilo=new HiloProgreso(getProgreso());
        
//Iniciamos el Hilo
        
hilo.start();
        
//Le damos tamaño y posición a nuestro Frame
        
this.setLocation(200,200);
        
this.setSize(472,249);
        
//Liberamos recursos
        
hilo=null;

           
          }

    
/** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    
@SuppressWarnings("unchecked")
    
// <editor-fold defaultstate="collapsed" desc="Generated Code">
    
private void initComponents() {

        
jPanel1 = new javax.swing.JPanel();
        
jPanel2 = new javax.swing.JPanel();
        
jLabel1 = new javax.swing.JLabel();
        
progreso = new javax.swing.JProgressBar();

        
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        
jPanel1.setName("jPanel1"); // NOI18N
        
jPanel1.setLayout(new java.awt.BorderLayout());
        
getContentPane().add(jPanel1java.awt.BorderLayout.LINE_START);

        
jPanel2.setName("jPanel2"); // NOI18N
        
jPanel2.setLayout(new java.awt.BorderLayout());

        
jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        
org.jdesktop.application.ResourceMap resourceMap org.jdesktop.application.Application.getInstance(Splash.ProyectoFinalApp.class).getContext().getResourceMap(principal.class);
        
jLabel1.setIcon(resourceMap.getIcon("jLabel1.icon")); // NOI18N
        
jLabel1.setText(resourceMap.getString("jLabel1.text")); // NOI18N
        
jLabel1.setName("jLabel1"); // NOI18N
        
jPanel2.add(jLabel1java.awt.BorderLayout.CENTER);

        
progreso.setName("progreso"); // NOI18N
        
jPanel2.add(progresojava.awt.BorderLayout.PAGE_END);

        
getContentPane().add(jPanel2java.awt.BorderLayout.CENTER);

        
pack();
    }
// </editor-fold>

    /**
    * @param args the command line arguments
    */
    
public static void main(String args[]) {
        
java.awt.EventQueue.invokeLater(new Runnable() {
            public 
void run() {
                new 
principal().setVisible(true);
            }
        });
    }

    
// Variables declaration - do not modify
    
private javax.swing.JLabel jLabel1;
    private 
javax.swing.JPanel jPanel1;
    private 
javax.swing.JPanel jPanel2;
    private 
javax.swing.JProgressBar progreso;
    
// End of variables declaration

    /**
     * @return the progreso
     */
    
public javax.swing.JProgressBar getProgreso() {
        return 
progreso;
    }
    public 
void  iniciarSplash() {
        
this.progreso.setBorderPainted(true);
        
this.progreso.setForeground(new Color(5050153100));
        
this.progreso.setStringPainted(true);
    }

    
/**
     * @param progreso the progreso to set
     */
    
public void setProgreso(javax.swing.JProgressBar progreso) {
        
this.progreso progreso;
    }


  #3 (permalink)  
Antiguo 29/03/2010, 17:26
 
Fecha de Ingreso: septiembre-2009
Mensajes: 63
Antigüedad: 14 años, 7 meses
Puntos: 0
Respuesta: Implementacion de Una ProgressBar.

Y el codigo de la clase debe quedar asi

Código PHP:
package Splash;
import javax.swing.JProgressBar;

/**
 *
 * @author Admin
 */
public class HiloProgreso extends Thread
        
{
        
JProgressBar progreso;
            public 
HiloProgreso(JProgressBar progreso1)
        {
            
super();
            
this.progreso=progreso1;

}
            public 
void  run()
    {
        for(
int i=1;i<=100;i++)
        {
            
progreso.setValue(i);
            
pausa(10); 
Pero ahora lo que quiero hacer es que cuando la barra de progreso llegue al 100% automaticamente me llame o aparezca la ventana x.

Como podria hacer eso??

Saludos
  #4 (permalink)  
Antiguo 25/06/2013, 13:22
 
Fecha de Ingreso: noviembre-2006
Mensajes: 19
Antigüedad: 17 años, 5 meses
Puntos: 0
Respuesta: Implementacion de Una ProgressBar.

al final del proceso de tu barra agrega esto

JOptionPane.showMessageDialog(null,
"CUERPO DEL MENSAJE ","TITULO",JOptionPane.INFORMATION_MESSAGE);

Etiquetas: implementacion, progressbar
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 17:49.