JProgressBar

JProgressBar

Have written the following code (with help from this website).My problem is that i want the JProgressBar to disappear and a new JFrame to appear as soon as the progress bar is complete. Please Help!!!!!!

Here is my code

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class Progress
{
 JFrame jf;
 JProgressBar jpb;
 Thread runner;
 int num = 0;
 Progress()
 {
  JFrame jf=new JFrame();
  jpb=new JProgressBar(0,100);
  jpb.setValue(0);
  jpb.setStringPainted(true);
  jpb.setString("Loading....");
  jf.add(jpb);
  jf.setSize(500,25);
  jf.setUndecorated(true);
  jf.setVisible(true);
  jf.setResizable(false);
  jf.setLocation(450,250);
 }
 public void iterate()
 {
  while (num < 1000) 
  {
   jpb.setValue(num);
   try{
    Thread.sleep(500);
   }
   catch (InterruptedException e){ }
   num += 10;
   if(num==100)
    new Screen1();
  }
 }
 public static void main(String args[])
 {
  Progress p=new Progress();
  p.iterate();
 }
}

PlEASE HELP!!!!!

View Answers

January 4, 2012 at 5:22 PM

1)Progress.java:

import java.awt.*;
import javax.swing.*;
import java.awt.event.*;

public class Progress{
 JFrame jf;
 JProgressBar jpb;
 Thread runner;
 int num = 0;
 Progress(){
  JFrame jf=new JFrame();
  jpb=new JProgressBar(0,100);
  jpb.setValue(0);
  jpb.setStringPainted(true);
  jpb.setString("Loading....");
  jf.add(jpb);
  jf.setSize(500,25);
  jf.setUndecorated(true);
  jf.setVisible(true);
  jf.setResizable(false);
  jf.setLocation(450,250);
 }
 public void iterate(){
  while (num < 1000){
   jpb.setValue(num);
   try{
    Thread.sleep(500);
   }
   catch (InterruptedException e){ }
   num += 10;
   if(num==100)
   new NextPage().setVisible(true);
   }
  }
 public static void main(String args[]){
  Progress p=new Progress();
  p.iterate();
 }
}

2)NextPage.java:

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

class NextPage extends JFrame
{
  NextPage()
   {
     setLayout(null);
     setDefaultCloseOperation(javax.swing. WindowConstants.DISPOSE_ON_CLOSE);
     JLabel lab=new JLabel("Welcome  ");
     lab.setBounds(10,10,500,20);
     add(lab);
     setSize(300, 100);
      }
 }

January 5, 2012 at 11:23 AM

Thanx for your help.But i want the JProgressBar to disappear and only the JFrame of the file NextPage.java to be displayed on the screen. Please help!!!!!









Related Tutorials/Questions & Answers:
JProgressBar
this website).My problem is that i want the JProgressBar to disappear and a new JFrame... class Progress { JFrame jf; JProgressBar jpb; Thread runner; int num = 0; Progress() { JFrame jf=new JFrame(); jpb=new JProgressBar(0,100
live JProgressbar
live JProgressbar   How to make a live JProgressbar in NetBeans
Advertisements
JProgressBar
Progress Bar - Swing AWT
ActionListener { JProgressBar pb = new JProgressBar(); JButton progress1 = new... interval = 1000; JProgressBar pb = new JProgressBar(); JButton progress1 = new
Progress Bar in Java Swing
has been explained as follows: JProgressBar: This is the class which creates the progress bar using it's constructor JProgressBar() to show the status of your process completion. The constructor JProgressBar() takes two argument
Progress Bar in Java
for the implementation of Progress Bar is JProgressBar Class Code Description ...; {   JLabel l1;   JProgressBar current;   ...; pane.setLayout(new GridLayout());    current = new JProgressBar
Progress Bar in Java
for the implementation of Progress Bar is JProgressBar Class Code Description ...; {   JLabel l1;   JProgressBar current;   ...; pane.setLayout(new GridLayout());    current = new JProgressBar(0
Using Progress Bar in java apps
("Start"); final JProgressBar pb = new JProgressBar(0, 20); pb.setValue(0... JProgressBar pb = new JProgressBar(0, 20); pb.setValue(0
Java + Timer concept - Java Beginners
label; JProgressBar pb; Timer timer; JButton button; public...()); pb = new JProgressBar(0, 20); pb.setValue(0
progress bar in google map - Development process
JProgressBar progress; private JButton button; private JLabel label1... Dimension(280, 24 )); topPanel.add(label1); progress = new JProgressBar
Java swing - Java Beginners
= 1000; int i; JLabel label; JProgressBar pb; Timer timer; JButton button...()); pb = new JProgressBar(0, 20); pb.setValue(0); pb.setStringPainted(true
Creating a Frame
   JSlider Component    JProgressBar Component
Sitemap Java Swing Tutorial
| JProgressBar Component | Creating Menus | Creating a Popup Menu
What is Java Swing?
Here the popup menu and the separator are available. JProgressBar
Java Swing Tutorials
.      JProgressBar Component In this section, you can

Ads