CONSTRUCTORS OF PROGRESSBAR:
JProgressBar()
By using this constructor we can create a progress bar with initial value of zero and ending value of 100.we can also set minimum and maximum value of progress bar by methods as we done in this program.
JProgressBar(int)
Creates a progress bar with orientation if user sets 1 vertical progress bar will create and if user set 0 horizontal progress bar will
create.
JProgressBar(int,int,int)
In this constructor first value determines the the orientation of progress bar and last two value specify the minimum and maximum values of progress bar.
JProgressBar(int,int)
Starting and ending value of constructor can also be define by using this constructor.
CODING:
import javax.swing.*;import java.awt.*;
class prog extends JFrame
{
JProgressBar my;
prog()
{
setTitle("JProgressBar");
FlowLayout f=new FlowLayout();
setLayout(f);
setSize(700,200);
setVisible(true);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
my = new JProgressBar();
my.setMinimum(0);
my.setMaximum(100);
my.setValue(25);
my.setStringPainted(true);
my.setBackground(Color.CYAN);
add(my);
}
}
class myprogress {
public static void main(String[] args)
{
prog fr = new prog();
}
}
0 comments:
Post a Comment