How to Make Loading (Delay Time) in Java GUI Programming

Monday, July 25, 2011

Making loading time delay in java, how to make time delay, in java gui programming, what I'll do to make loading time in java programming, in java programming, I can't make loading time in java program, improve your java program with loading time, make a timer in java GUI, using timer in java program, add a loading timer in java program

I give this trick just for additions to the Java programs that you create, perhaps look more appealing when you add a timer or loading into the program. When I think when creating a program, it's good to add a timer on the program.

Maybe this trick can be an inspiration for those of you who are developing programs that you create. Improve your creativity when making program. The higher your creativity, the higher the others will pay you.

Program code below will display a picture like this:



white text will gone in 5 seconds.



This is determined by the code:

waitNSeconds(5);

if you change the number 5 to number 6, then the text will disappear in seconds-6

This is the Source Code :

________________________________________________

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

public class loading extends JFrame {

JLabel label = new JLabel("Dalam 5 detik Tulisan menghilang");
JPanel panel = new JPanel();


loading(){
super("Loading");
setSize(300,180);
setLocation(100,100);
panel.setLayout(null);
panel.setBackground(Color.BLACK);
label.setBounds(50,50,200,40);
label.setForeground(Color.WHITE);

panel.add(label);


getContentPane().add(panel);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setVisible(true);
label.setVisible(true);
waitNSeconds(5);
label.setVisible(false);
}

public void wait1second()
// post: pause for one second
{
long now = System.currentTimeMillis();
long then = now + 1000; // one second of milliseconds
while (System.currentTimeMillis() < then) {
label.setVisible(true);
}
}

public void waitNSeconds(int number)
// pre: number >= 0
// post: pause for number seconds
{
int i;
for (i = 0; i < number; i++){
wait1second();
}
}

public static void main(String[] args) {
loading frameTabel = new loading();
}
}

____________________________________________________
Good Luck,,,

2 comments:

luckys said...

best kitchen weighing scale 

This post is very simple to read and appreciate without leaving any details out. Great work ! Call center Software Solution

Post a Comment

 
 
 
 
Copyright © Programming Tricks