JProgressBar

Ads

 
 

Share on Google+Share on Google+

Aabid Nakhuda
JProgressBar
2 Answer(s)      5 years and 4 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!!!!!

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


Ads









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
Tutorials   
Java Spring Hibernate Struts Training ClassNotFoundException HttpRequestInterceptor java.lang.noclassdeffounderror: org/apache/http/httprequest noclassdeffounderror: org/apache/http/client/methods/httpurirequest java.lang.NoClassDefFoundError: org/apache/http/client/HttpClient How do I resolve this Java Class not found exception? httpclient java.lang.NoClassDefFoundError Apache Commons ioutils maven dependency Read/Convert an inputStream to a String What is the meaning of Java Platform? Why Java is a platform independent language? What is the benefits of learning Core Java? Which technology should I learn after Java? What is array in java with example? How to Convert ArrayList to Array? How to substring in Java? How to format number in Java? What is instance variable in Java? How to download MySQL JDBC driver? What is Calendar class in Java? Which is the best Java tutorials for beginners? How to rename a file in Java? How to delete file in Java code? How to get day from date in Java using Calendar? How to get day of week in Java? How to calculate Date Difference in Java? How to compare date in Java? How to declare array in Java? How to calculate average of array in Java? What is Array in Java? write a java program to find the summation of all the integers entered on command line Sum of two numbers using command line arguments in Java How to create and use Array in Java? How to pass command line arguments in Java? How to create Applet Hello World? Appending String efficiently in Java How to append String in Java? How to list even numbers between 1 and 100? How to add BigDecimal in Java? What is Abstraction In Java? Which is best Beginners Java Tutorial? What is java.util package? Create list from array in Java Filter collection in Java 8 What is the best way to filter a Java Collection? Easy way to transform Collection to Array? How to convert Collection to Array in Java? What are Basic Java Language Elements? Advanced Java Tutorials in 2017 Java brief history Best Reasons to learn Java

Ads

 
Advertisement null

Ads