ASWing Tree

 

package {
        import flash.display.Sprite;
        
        import org.aswing.AsWingManager;
        import org.aswing.BorderLayout;
        import org.aswing.JFrame;
        import org.aswing.JPanel;
        import org.aswing.JScrollPane;
        import org.aswing.JTree;
        import org.aswing.tree.DefaultMutableTreeNode;
        import org.aswing.tree.DefaultTreeModel;
        
        public class JTreeExample extends Sprite {
                private var tree:JTree;
                private var frame:JFrame;
                public function JTreeExample() {
                        super();
                        AsWingManager.initAsStandard(this);
                        frame=new JFrame(this,"JTreeExample1");
                        var pane:JPanel=new JPanel(new BorderLayout  );
                        var root:DefaultMutableTreeNode=new DefaultMutableTreeNode(createItem("JTree"));
                        var parent:DefaultMutableTreeNode;
                        parent=new DefaultMutableTreeNode(createItem("folder1"));
                        root.append(parent);
                        var i:int;
                        for (i=0; i < 3; i++) {
                                parent.append(new DefaultMutableTreeNode(createItem("itemone " + i)));
                        }
                        parent=new DefaultMutableTreeNode(createItem("folder2"));
                        root.append(parent);                        
                        
                        var model:DefaultTreeModel=new DefaultTreeModel(root);
                        
                        tree=new JTree  ;
                        tree.setModel(model);
                        pane.append(new JScrollPane(tree),BorderLayout.CENTER);
                        frame.setContentPane(pane);
                        frame.setSizeWH(300,300);
                        frame.show();
                }
                private function createItem(value:String):* {
                        return value;
                }
        }
}

 

你可能感兴趣的:(Flash)