Using progress bars and sliders : Slider « Swing JFC « Java

Java
1. 2D Graphics GUI
2. 3D
3. Advanced Graphics
4. Ant
5. Apache Common
6. Chart
7. Class
8. Collections Data Structure
9. Data Type
10. Database SQL JDBC
11. Design Pattern
12. Development Class
13. EJB3
14. Email
15. Event
16. File Input Output
17. Game
18. Generics
19. GWT
20. Hibernate
21. I18N
22. J2EE
23. J2ME
24. JDK 6
25. JNDI LDAP
26. JPA
27. JSP
28. JSTL
29. Language Basics
30. Network Protocol
31. PDF RTF
32. Reflection
33. Regular Expressions
34. Scripting
35. Security
36. Servlets
37. Spring
38. Swing Components
39. Swing JFC
40. SWT JFace Eclipse
41. Threads
42. Tiny Application
43. Velocity
44. Web Services SOA
45. XML
Java Tutorial
Java Source Code / Java Documentation
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java » Swing JFC » SliderScreenshots 
Using progress bars and sliders
Using progress bars and sliders
 
// : c14:Progress.java
// Using progress bars and sliders.
// <applet code=Progress width=300 height=200></applet>
// From 'Thinking in Java, 3rd ed.' (c) Bruce Eckel 2002
// www.BruceEckel.com. See copyright notice in CopyRight.txt.

import java.awt.Container;
import java.awt.GridLayout;

import javax.swing.JApplet;
import javax.swing.JFrame;
import javax.swing.JProgressBar;
import javax.swing.JSlider;
import javax.swing.border.TitledBorder;

public class Progress extends JApplet {
  private JProgressBar pb = new JProgressBar();

  private JSlider sb = new JSlider(JSlider.HORIZONTAL, 010060);

  public void init() {
    Container cp = getContentPane();
    cp.setLayout(new GridLayout(21));
    cp.add(pb);
    sb.setValue(0);
    sb.setPaintTicks(true);
    sb.setMajorTickSpacing(20);
    sb.setMinorTickSpacing(5);
    sb.setBorder(new TitledBorder("Slide Me"));
    pb.setModel(sb.getModel())// Share model
    cp.add(sb);
  }

  public static void main(String[] args) {
    run(new Progress()300200);
  }

  public static void run(JApplet applet, int width, int height) {
    JFrame frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.getContentPane().add(applet);
    frame.setSize(width, height);
    applet.init();
    applet.start();
    frame.setVisible(true);
  }
///:~



           
         
  
Related examples in the same category
1. Creating a JSlider Component
2. Create a horizontal slider with custom min, max, and value
3. Create a vertical slider with min=0, max=100, value=50
4. Create a vertical slider with custom min, max, and value
5. Make the horizontal slider move right-to-left
6. Make it vertical and move bottom-to-top
7. Make it vertical and move top-to-bottom
8. Get the extent
9. Getting and Setting the Values of a JSlider Component
10. Drawing with Swing, using a JSliderDrawing with Swing, using a JSlider
11. A slider with tick marks and labels
12. An example of JSlider with default labelsAn example of JSlider with default labels
13. Set minor tick marks every 5 units
14. Set major tick marks every 25 units
15. Slider SampleSlider Sample
16. JSlider Sample 2JSlider Sample 2
17. Slider ChangeListenerSlider ChangeListener
18. Inverted SlidersInverted Sliders
19. Slider change action listenerSlider change action listener
20. Date sliderDate slider
21. Slider TestSlider Test
22. Tick SlidersTick Sliders
23. Scroll SliderScroll Slider
24. Text SliderText Slider
25. Change the minimum value
26. Change the maximum value
27. Set the extent
28. Move the slider by a fixed amount: the extent.
29. Set all the values at once by using the model
30. Set the value; the new value will be forced into the bar's range
31. Listening for Value Changes in a JSlider Component
32. Constraining JSlider Component Values to Tick Marks
33. Determine if currently snapping to tick marks
34. Snap to tick marks
35. Set to a spot between tick marks; the value moves to closest tick mark
36. Determine if currently painting labels
37. Showing Tick Marks on a JSlider Component
38. Show tick marks
39. The slider allows you to use an arbitrary label at any particular major tick mark.
40. Showing Tick-Mark Labels on a JSlider Component
41. Hide the track
42. Sample SlidersSample Sliders
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.