Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


Aabid Nakhuda
JProgressBar
2 Answer(s)      2 years and 8 months ago
Posted in : Java Beginners


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!!!!!


Advertisement
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
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
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 as parameter in which
Progress Bar in Java
for the implementation of Progress Bar is JProgressBar Class Code Description ...;   JProgressBar current;    JTextArea ta;   ...());    current = new JProgressBar(0, 100);   
Progress Bar in Java
for the implementation of Progress Bar is JProgressBar Class Code Description ...;   JProgressBar current;    JTextArea ta;  ...());    current = new JProgressBar(0, 100);   
Using Progress Bar in java apps
JProgressBar pb = new JProgressBar(0, 20); pb.setValue(0... JButton button = new JButton("Start"); final JProgressBar pb = new JProgressBar
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 + Timer concept - Java Beginners
label; JProgressBar pb; Timer timer; JButton button; public...()); pb = new JProgressBar(0, 20); pb.setValue(0
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
JSpinner Component | JSlider Component | JProgressBar Component
What is Java Swing?
the popup menu and the separator are available. JProgressBar It shows
Java Swing Tutorials
; JProgressBar Component In this section, you can learn how to handle progress
Advertisements
 

 

 

DMCA.com