Step 1: Basic Setup
The first thing needed is an
instance of GanttChart (or
DualGanttChart if split view
functionallity is needed). In most cases it is sufficient
to use the default empty constructor. There are several
other constructors that allow you to pass in a model or a
component factory or both. The default constructor uses an
instance of DefaultGanttChartModel and
DefaultComponentFactory.
GanttChart gc = new GanttChart();
This component could now be added to any window (frame or dialog) but FlexGantt provides a specialized frame called GanttChartFrame that adds out-of-the-box functionality that most scheduling applications need anyway. They are: busy cursor management, toolbar support, status bar support. We use this frame type because this is a quickstart guide and we are trying to get started as quickly as possible.
GanttChartFrame<GanttChart> frame = new GanttChartFrame<GanttChart>("Step 1", gc);
To ensure that the virtual machine exits when the frame gets closed we set the default close operation to EXIT_ON_CLOSE.
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Now we only need to make the frame visible in order to see our first Gantt chart on the screen.
frame.setVisible(true);
All of the above steps combined and wrapped in a main() method result in the following short program:
Next Step: Step 2 Tree Nodes/**
* Copyright 2006, 2007
* Dirk Lemmermann Software & Consulting
* http://www.dlsc.com
*/
package com.dlsc.flexgantt.examples.jumpstart;
import javax.swing.JFrame;
import com.dlsc.flexgantt.swing.GanttChart;
import com.dlsc.flexgantt.swing.GanttChartFrame;
/**
* One of the steps used for the 'Jumpstart' tutorial. The step will create a
* basic Gantt chart. The chart will be populated with a default model and a
* single default node, which displays a default value as its key.
*
* @author Dirk Lemmermann
*/
public class Step1_Basic_Setup {
/**
* @param args
*/
public static void main(String[] args) {
/*
* Create a basic Gantt chart, which will use the default Gantt chart
* model. The default model itself will use the default Gantt chart node
* as a root object.
*/
GanttChart gc = new GanttChart();
/*
* Add the Gantt chart to a specialized frame class. The frame will
* automatically add a status bar and a glass pane (used for updating
* the cursor when commands get executed).
*/
GanttChartFrame<GanttChart> frame = new GanttChartFrame<GanttChart>("Step 1", gc);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
/*
* Show the frame. The split panel inside the Gantt chart will adjust to
* the preferred size of the left-hand side (the tree table).
*/
frame.setVisible(true);
}
}