java flex界面_JAVA甘特图控件FlexGantt使用教程:树节点(Tree Nodes)设置

最后整个设置完成代码:

/**

* Copyright 2006 - 2008

* Dirk Lemmermann Software & Consulting

*

http://www.dlsc.com

*/

package com.dlsc.flexgantt.examples.jumpstart;

import javax.swing.JFrame;

import com.dlsc.flexgantt.model.gantt.DefaultGanttChartModel;

import com.dlsc.flexgantt.model.gantt.DefaultGanttChartNode;

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

* couple of tree nodes and add them to the Gantt chart.

*

* @author Dirk Lemmermann

*/

public class Step2_Tree_Nodes {

/**

* The application‘s entry point.

Page

5

!

FlexGantt - Getting Started

*/

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();

/*

* Retrieve the default model and node from the Gantt chart.

*/

DefaultGanttChartModel model = (DefaultGanttChartModel) gc.getModel();

DefaultGanttChartNode root = (DefaultGanttChartNode) model.getRoot();

/*

* Add new nodes to the model and trigger an event so that the UI will

* update its state.

*/

DefaultGanttChartNode node1 = new DefaultGanttChartNode("Node 1");

DefaultGanttChartNode node2 = new DefaultGanttChartNode("Node 2");

DefaultGanttChartNode node3 = new DefaultGanttChartNode("Node 3");

node1.setKey("Key 1");

node2.setKey("Key 2");

node3.setKey("Key 3");

root.add(node1);

root.add(node2);

root.add(node3);

model.nodeStructureChanged(root); // the event

/*

* Add more nodes to node2.

*/

DefaultGanttChartNode node21 = new DefaultGanttChartNode("Node 21");

DefaultGanttChartNode node22 = new DefaultGanttChartNode("Node 22");

DefaultGanttChartNode node23 = new DefaultGanttChartNode("Node 23");

DefaultGanttChartNode node24 = new DefaultGanttChartNode("Node 24");

DefaultGanttChartNode node25 = new DefaultGanttChartNode("Node 25");

node21.setKey("Key 21");

node22.setKey("Key 22");

node23.setKey("Key 23");

node24.setKey("Key 24");

node25.setKey("Key 25");

node2.add(node21);

node2.add(node22);

node2.add(node23);

node2.add(node24);

node2.add(node25);

model.nodeStructureChanged(node2); // another event

/*

* 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 frame = new GanttChartFrame(

"Step 2", 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);

}

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值