Chapter 2. How to Use the Components

Table of Contents

1. Before We Begin
2. Using a JDateComponent
2.1. Selecting a Date
2.2. Allowing Empty Selection or Null Dates
2.3. Concepts: About Date Selection Models
2.4. Listening for Changes on Date Selection Model
2.5. Implementing a Date Selection Model
2.6. Listening for Action Events
2.7. Associating Date Actions with Key Strokes
2.8. Disabling the Component
3. Using a JDateEditComponent
3.1. Setting an Appropriate Date Format
3.2. Concepts: About Date Models
3.3. Listening for Changes on Date Model
3.4. Concepts: About Date Parsers
3.5. Implementing a Date Parser
3.6. Configuring Validation Behavior
4. Using the JMonth Component
4.1. Selecting Dates
4.2. Changing the Selection Type
4.3. Localizing the Component
4.4. Changing Colors and Font
4.5. Concepts: About Date Renderers
4.6. Implementing a Date Renderer
4.7. Configuring the Grid
4.8. Showing Week Numbers and Names
4.9. Concepts: About Month Models
4.10. Working with a Month Model (First Day of Week, Displayed Month)
4.11. Using the Keyboard
5. Using the JMonthView Component
5.1. Localizing the Component
5.2. Allowing Empty Selection
5.3. Showing the Today Button
5.4. Showing the Status Bar
6. Using the JDatePicker Component
6.1. Working with an Editable Date Picker
6.2. Changing the Background Color
6.3. Configuring the Drop Down Calendar
6.4. Localizing the Component
6.5. Using a Custom Look and Feel
6.6. Installing a Date Cell Editor for JTable
7. Using the JDateField Component
8. How to Create a Completely New Look for the Components
8.1. Concepts: About UI delegates
8.2. Per-Application vs Per-Component Customization
8.3. Creating a Custom UI Delegate
8.4. Example 1: Read-Only Calendar Title
8.5. Example 2: Spinner Calendar (Windows Date/Time Calendar)
8.6. Example 3: Image Scroll Buttons for the Calendar

1. Before We Begin

This tutorial is intended for developers who want to use the Java Date Picker components in their applications. It shows how the components can be used effectively and introduces an important part of the API. The following image shows how the API is structured:

Figure 2.1. Java Date Picker API Structure

Java Date Picker API Structure

The blue components are concrete while the gray ones are abstract. The following sections give a detailed description of each one of them.