aswing JTable用法

View Code
public class TestJTable extends Sprite
    {
        private static const color : ASColor = new ASColor ( 0x5B411E , 1 );
        //空皮肤的边界
        private static const border : SkinEmptyBorder = new SkinEmptyBorder ( 0 , 0 , 0 , 0 );
        
        public function TestJTable()
        {
            AsWingManager.initAsStandard(this);
            
            var window:JWindow = new JWindow();
            window.setSizeWH(400,200);
            window.setLocationXY(10,10);
            window.setBorder(new LineBorder());
            window.getContentPane().setLayout( new FlowLayout() );
            window.show();
            
            var column:Array = ["姓名","性别","年龄"];
            var data:Array = [["Sammy","","25"],["Ruby","","23"]];
            
            var model:DefaultTableModel = new DefaultTableModel().initWithDataNames(data,column);
            
            var table:JTable = new JTable(model);
            //水平间隔线
            table.setShowHorizontalLines(false);
            //竖直间隔线
            table.setShowVerticalLines(false);
            //设置字体颜色,前景色
//            table.setForeground(color);
            //设置选中行的时候的字体颜色
            table.setSelectionForeground(color);
            table.setBorder ( border );
            //拉伸的模式,随意拉伸
            table.setAutoResizeMode ( JTable.AUTO_RESIZE_OFF );
            //只能选择一行
            table.setSelectionMode ( JTable.SINGLE_SELECTION );
            //行高
            table.setRowHeight ( 40 );
            //设置为透明
            table.setOpaque ( false );
            //设置单元格border
            table.setShowGrid ( false );
            
            window.getContentPane().append(table);
        }
    }

posted on 2012-05-08 11:51  防空洞123  阅读(507)  评论(0编辑  收藏  举报

导航