♠ Posted by Unknown in Adv Java at 00:50
Sliders & Progress bars
A
slider allows the user to input data by moving a point back and forth, which is
intuitive in some situations. A progress bar displays data in a relative
fashion from “full” to “empty” so the user gets a perspective.
Example:
import
javax.swing.*;
import
java.awt.*;
import
java.awt.event.*;
import
javax.swing.event.*;
import
javax.swing.border.*;
public class
Progress extends JApplet
{
JProgressBar pb = new JProgressBar();
JSlider sb = new
JSlider(JSlider.HORIZONTAL, 0, 100, 60);
public void init()
{
Container contentPane =
getContentPane();
contentPane.setLayout(new
GridLayout(2,1));
contentPane.add(pb);
sb.setValue(0);
sb.setPaintTicks(true);
sb.setMajorTickSpacing(20);
sb.setMinorTickSpacing(5);
sb.setBorder(new
TitledBorder("Slide Me"));
pb.setModel(sb.getModel());
contentPane.add(sb);
}
}
0 comments:
Post a Comment