Date spinner : Spinner « Swing JFC « Java

Home
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.JavaFX
25.JDK 6
26.JDK 7
27.JNDI LDAP
28.JPA
29.JSP
30.JSTL
31.Language Basics
32.Network Protocol
33.PDF RTF
34.Reflection
35.Regular Expressions
36.Scripting
37.Security
38.Servlets
39.Spring
40.Swing Components
41.Swing JFC
42.SWT JFace Eclipse
43.Threads
44.Tiny Application
45.Velocity
46.Web Services SOA
47.XML
Java » Swing JFC » Spinner 




Date spinner
   

import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;

import javax.swing.JFrame;
import javax.swing.JSpinner;
import javax.swing.SpinnerDateModel;
import javax.swing.SpinnerListModel;
import javax.swing.SpinnerNumberModel;

public class Main extends JFrame {
  public Main() {
    JSpinner m_dateSpinner;
    SpinnerDateModel m_dateSpinnerModel;
    Calendar rightNow = Calendar.getInstance();

    Date current = rightNow.getTime();

    rightNow.set(Calendar.HOUR_OF_DAY, -24);
    Date start = rightNow.getTime();
    rightNow.set(Calendar.HOUR_OF_DAY, 48);
    Date end = rightNow.getTime();

    int step = Calendar.HOUR_OF_DAY;
    m_dateSpinnerModel = new SpinnerDateModel(current, start, end, step);
    m_dateSpinner = new JSpinner(m_dateSpinnerModel);
    add(m_dateSpinner);
  }
  public static void main(String argv[]) {
    Main spinnerFrame = new Main();
    spinnerFrame.setSize(350200);
    spinnerFrame.setVisible(true);
  }
}

   
    
    
  














Related examples in the same category
1.A program to test spinners.A program to test spinners.
2.An implementation of JSpinner with customized content--iconsAn implementation of JSpinner with customized content--icons
3.A quick test of various spinnersA quick test of various spinners
4.An example of JSpinner with a custom editorAn example of JSpinner with a custom editor
5.Create a spinnerCreate a spinner
6.Demonstrating the JSpinner ComponentDemonstrating the JSpinner Component
7.Demonstrate the Swing Spinner control
8.Spinner 2Spinner 2
9.Listening for Changes to the Value in a JSpinner Component
10.Creating a SpinnerListModel That Loops Through Its Values
11.Customizing the Editor in a JSpinner Component: Create a color spinner
12.Setting the Margin Space on a JSpinner Component
13.Limiting the Values in a Number JSpinner Component
14.Disabling Keyboard Editing in a JSpinner Component
15.Creating an Hour JSpinner Component
16.Creating a JSpinner Component: A number spinner:
17.A list spinner
18.A date spinner
19.A spinner of dates
20.Use an Icon Editor for use with the JSpinner component
21.Use images in tooltips
22.Number spinner
23.List based spinner
24.Java Spinner ComponentJava Spinner Component
25.Enhanced Spinner List Formatter
26.Enhanced Spinner List Model
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.