Overview
JTimeline displays events in chronological order with:
Vertical or horizontal orientation
Custom icons per event
Color-coded indicators
Time labels
Rich custom content support
Automatic connector lines between events
Constructor
Creates a new timeline in vertical orientation by default.
Basic Usage
JTimeline timeline = new JTimeline ();
timeline . addEvent ( "Order Placed" , "Customer placed order #1234" , "2 hours ago" );
timeline . addEvent ( "Payment Confirmed" , "Payment received" , "1 hour ago" );
timeline . addEvent ( "Shipped" , "Package shipped via FedEx" , "30 min ago" );
timeline . addEvent ( "Delivered" , "Package delivered" , "Just now" );
Orientation
setOrientation(orientation)
Sets the timeline orientation.
orientation (Orientation): VERTICAL or HORIZONTAL
timeline . setOrientation ( Orientation . HORIZONTAL );
Returns the current orientation.
Adding Events
addEvent(title, description, time)
Adds a simple text event to the timeline.
title (String): Event title
description (String): Event description
time (String): Time label (e.g., “2 hours ago”, “Jan 15, 2024”)
Adds a fully configured Event object to the timeline.
event (JTimeline.Event): Event instance with custom configuration
JTimeline . Event event = new JTimeline. Event (
"Deployment" ,
"Application deployed to production" ,
"10:30 AM"
);
event . setColorClass ( "success" );
event . setIcon ( new JIcon ( "check-circle" ). view ());
timeline . addEvent (event);
Returns the observable list of events. Changes to this list automatically update the timeline.
Event Class
The JTimeline.Event class represents a single timeline event.
Constructor
Event(title, description, time)
Creates a new event.
title (String): Event title
description (String): Event description
time (String): Time label
Properties
Sets the event title.
title (String): Title text
setDescription(description)
Sets the event description.
description (String): Description text
Returns the event description.
Sets the time label.
time (String): Time text (e.g., “2 hours ago”, “Jan 15, 2024”)
Customization
Sets a custom icon for the event indicator.
icon (Node): JavaFX Node (typically JIcon.view()), or null for default circle
event . setIcon ( new JIcon ( "check-circle" ). view ());
Returns the custom icon, or null if using default circle.
setColorClass(colorClass)
Sets the color variant for the indicator and connector line.
colorClass (String): Color class - “primary”, “success”, “danger”, “warning”, “info”, “slate”
event . setColorClass ( "success" ); // Green indicator
event . setColorClass ( "danger" ); // Red indicator
setCustomContent(content)
Sets custom JavaFX content to display below the description.
content (Node): Custom content node
// Add a button to the event
JButton viewBtn = new JButton ( "View Details" );
event . setCustomContent (viewBtn);
// Add a complex layout
VBox details = new VBox (
new JLabel ( "Location: New York" ),
new JLabel ( "Status: Completed" )
);
event . setCustomContent (details);
Returns the custom content node.
Advanced Example
JTimeline timeline = new JTimeline ();
// Event 1: Started (blue)
JTimeline . Event started = new JTimeline. Event (
"Project Started" ,
"Initial planning and requirements gathering" ,
"Jan 1, 2024"
);
started . setColorClass ( "primary" );
started . setIcon ( new JIcon ( "play-circle" ). view ());
timeline . addEvent (started);
// Event 2: Development (info)
JTimeline . Event dev = new JTimeline. Event (
"Development Phase" ,
"Sprint 1-4 completed successfully" ,
"Jan 15, 2024"
);
dev . setColorClass ( "info" );
dev . setIcon ( new JIcon ( "code" ). view ());
// Add custom content with progress
JProgressBar progress = new JProgressBar ( 0.75 );
progress . setLabel ( "75% Complete" );
dev . setCustomContent (progress);
timeline . addEvent (dev);
// Event 3: Testing (warning)
JTimeline . Event testing = new JTimeline. Event (
"Testing" ,
"QA testing in progress" ,
"Feb 1, 2024"
);
testing . setColorClass ( "warning" );
testing . setIcon ( new JIcon ( "bug" ). view ());
timeline . addEvent (testing);
// Event 4: Deployed (success)
JTimeline . Event deployed = new JTimeline. Event (
"Deployed to Production" ,
"Successfully deployed v1.0" ,
"Feb 15, 2024"
);
deployed . setColorClass ( "success" );
deployed . setIcon ( new JIcon ( "check-circle" ). view ());
timeline . addEvent (deployed);
// Horizontal orientation for compact view
timeline . setOrientation ( Orientation . HORIZONTAL );
Visual Behavior
Vertical Mode
Events stack vertically
Time label appears beside title
Connector lines run vertically between indicators
Content flows downward
Horizontal Mode
Events arranged horizontally
Equal width for each event
Time label appears below title
Connector lines run horizontally between indicators
Connector Lines
Automatically drawn between events
Last event has no trailing line
Inherits color from event’s colorClass
Slight padding separates line from indicator