by Dinesh Thakur Category: Swing

A slider allows the user to enter a point moving data back and forth, which is intuitive in some situations (volume control, for example). a progress bar displays data in a relative form of "full" to "empty" so the user gets a perspective.

The key to hooking the two components together is to share your model in the line:
The JProgressBar is fairly straightforward, but the JSlider has a lot of options, such as orientation and major and minor brands.
Here is the example of Sliders and Progress bars

/* <applet code= Progress.class width=320 height=200> </applet> */ import javax.swing.*;

import java.awt.*;
import java.awt.event.*;
import javax.swing.event.*;
import javax.swing.border.*;
public class Progress extends JApplet
           JProgressBar ProgressBar = new JProgressBar();
           JSlider Slider = new JSlider(JSlider.HORIZONTAL, 0, 100, 60);
           public void init()
                Frame frm = (Frame)this.getParent().getParent();
                frm.setTitle("Sliders and Progress bars");
                Container container = getContentPane();
                container.setLayout(new GridLayout(2,1));
                Slider.setBorder(new TitledBorder("Slide Bar (JSlider)"));

Sliders and Progress bars

About Dinesh Thakur

Dinesh ThakurDinesh Thakur holds an B.C.A, MCSE, MCDBA, CCNA, CCNP, A+, SCJP certifications. Dinesh authors the hugely popular blog. Where he writes how-to guides around Computer fundamental , computer software, Computer programming, and web apps. For any type of query or something that you think is missing, please feel free to Contact us.

Related Articles