Results 1 to 6 of 6

Thread: How to create a Loading bar in Java?

  1. #1
    Join Date
    Dec 2009
    Posts
    18

    How to create a Loading bar in Java?

    I am using the Dell desktop at my home. I am basically a intermediate programmer and loves to do programming. This days i am learning the programming languages: Core Java, SQL, PHP, HTML and C sharp. I got project to develop, in which i want to create a loading bar at the starting of the project, but i don't how to code it or make it? Please somebody help me on this.

  2. #2
    Join Date
    Jan 2008
    Posts
    1,521

    Re: How to create a Loading bar in Java?

    I think loading bar means the progress bar. The progress bar are used mostly in indeterminate mode displays animation for indicating that some work is occurring, so please wait. In java, the swing function provides three classes to help you for using the progress bars. And the classes are as follows: 1] JProgressBar, 2] ProgressMonitor, and 3] ProgressMonitorInputStream. You have to use either the progress bar or progress monitor class. Hope your problem will be fix.

  3. #3
    Join Date
    Feb 2008
    Posts
    1,852

    Re: How to create a Loading bar in Java?

    I am also using the Java language to develop the project and i used the JProgressBar and JScrollBar classes to create the loading bar(i.e progress bar). And for better/good outcome, you should put them in two different threads. One thread will do the loading and the other will display the loading bar. This will make your code simple to understand and if error comes you can easily solve it. Hope your problem will be solved soon.

  4. #4
    Join Date
    May 2008
    Posts
    2,389

    Re: How to create a Loading bar in Java?

    I think you mean progress bar (i.e loading bar). Mainly this progress bars are usually used for the long tasks to show the users that how much time/duration is left before the task is get completed. And this bars are implemented/ written in Swing using JProgressBar class. Hope you would be knowing how to use the swing function and coding of it. Hope your problem will get fix soon.

  5. #5
    Join Date
    Oct 2005
    Posts
    2,393

    Re: How to create a Loading bar in Java?

    Example of the progress bar code. It is not hard code, you to do addition of code i.e importing all the class related to program bar.
    public class DemoProgressBar {
    public static void main(String args[])
    {
    JProgressBar Demo1JProgressBar = new JProgressBar();
    Demo1JProgressBar.setValue(60);
    JProgressBar Demo2JProgressBar = new JProgressBar();
    Demo2JProgressBar.setValue(35);
    Demo2JProgressBar.setStringPainted(true);
    Border border = BorderFactory.createTitledBorder("Reading..");
    JProgressBar.setBorder(border);
    JProgressBar Demo2JProgressBar = new JProgressBar(JProgressBar.VERTICAL);
    Demo3JProgressBar.setValue(85);
    Demo3JProgressBar.setBorderPainted(false);

    JProgressBar DemoJProgressBar = new JProgressBar(JProgressBar.VERTICAL);
    Demo4JProgressBar.setValue(100);
    Demo4JProgressBar.setString("Done");
    Demo4JProgressBar.setStringPainted(true);

    JFrame theFrame = new JFrame("Progress Bars");
    theFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    Container contentPane = theFrame.getContentPane();
    contentPane.add(Demo1JProgressBar, BorderLayout.NORTH);
    contentPane.add(Demo2JProgressBar, BorderLayout.SOUTH);
    contentPane.add(Demo3JProgressBar, BorderLayout.EAST);
    contentPane.add(Demo4JProgressBar, BorderLayout.WEST);
    theFrame.setSize(400, 350);
    theFrame.setVisible(true);
    }
    }
    Use this code in your program. Hope your problem will be solved soon.

  6. #6
    Join Date
    Apr 2008
    Posts
    1,948

    Re: How to create a Loading bar in Java?

    According to me, if you want to show that a task of unknown duration is executing/running, then you can use the progress bar into indeterminate mode. When the progressbar/ loadingbar is in indeterminate mode, it will animates constantly to show that work is occurring. As soon as you can determine the tasks duration and amount of progress, you should update the progress bar's value and switch it back to determinate mode. Syntax of Progress bar:
    DemoprogressBar = new JProgressBar(0, task.getLengthOfTask());
    DemoprogressBar.setValue(0);
    DemoprogressBar.setStringPainted(true);

Similar Threads

  1. How to create Web Browser with the help of JAVA
    By StudyBoy in forum Software Development
    Replies: 7
    Last Post: 15-03-2012, 02:52 AM
  2. How to create an inner class in java?
    By MABON in forum Software Development
    Replies: 4
    Last Post: 01-02-2010, 04:40 PM
  3. Loading java files via HTTP
    By Xmen in forum Software Development
    Replies: 4
    Last Post: 18-11-2009, 09:03 PM
  4. How to create XML file in Java
    By Suzane in forum Software Development
    Replies: 3
    Last Post: 27-04-2009, 06:00 PM
  5. Loading Java Applet Failed
    By Sanith in forum Technology & Internet
    Replies: 2
    Last Post: 25-03-2009, 10:03 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,964,038.88102 seconds with 17 queries