AsWing GridLayoutデモ
GridLayoutは、コンテナーをグリッドに別けるレイアウトマネージャ。各グリッドの大きさはすべて等しく、コンポーネントはグリッドの大きさにレイアウトされる。
行数を基準にグリッドが作成されるが、行数が0の場合、列数を元にグリッドが作成される。
このムービーを再生するにはFlash Player 9が必要です。
/** * ... * @author Default * @version 0.1 */ import org.aswing.FlowLayout; import org.aswing.GridLayout; import org.aswing.JAdjuster; import org.aswing.JButton; import org.aswing.JFrame; import org.aswing.JLabel; import org.aswing.JSlider; import org.aswing.JSpacer; import org.aswing.JWindow; class Sample005 extends JWindow{ private var _frame:JFrame; private var _layout:GridLayout; private var _hslider:JSlider; private var _vslider:JSlider; private var _cajaster:JAdjuster; private var _rajaster:JAdjuster; public function Sample005() { super(_root, true); initUI(); } public static function main():Void { var app:Sample005 = new Sample005(); } private function initUI():Void { Stage.scaleMode = 'noScale'; setSize(400, 400); getContentPane().setLayout(new FlowLayout( FlowLayout.LEFT, 0, 0)); getContentPane().append(new JLabel('行')); _rajaster = new JAdjuster(3, 0); _rajaster.setValue(3); _rajaster.setMaximum(15); _rajaster.setMinimum(0); _rajaster.addActionListener(onRowsChanged, this); getContentPane().append(_rajaster); getContentPane().append(new JLabel('列')); _cajaster = new JAdjuster(3, 0); _cajaster.setValue(3); _cajaster.setMaximum(15); _cajaster.setMinimum(0); _cajaster.addActionListener(onColsChanged, this); getContentPane().append(_cajaster); getContentPane().append(new JSpacer(250, 0)); getContentPane().append(new JLabel('横間隔')); _hslider = new JSlider(0, 0, 30, 0); _hslider.addChangeListener(onHGapChanged, this); getContentPane().append(_hslider); getContentPane().append(new JSpacer(150, 0)); getContentPane().append(new JLabel('縦間隔')); _vslider = new JSlider(0, 0, 30, 0); _vslider.addChangeListener(onVGapChanged, this); getContentPane().append(_vslider); getContentPane().append(new JLabel()); _layout = new GridLayout(3, 4, 0, 0); _frame = new JFrame(this, 'Example of GridLayout'); _frame.setSize(400, 150); _frame.setLocation(0, 200); _frame.getContentPane().setLayout(_layout); _frame.getContentPane().append( new JButton('Button A')); _frame.getContentPane().append( new JButton('Button B')); _frame.getContentPane().append( new JButton('Button C')); _frame.getContentPane().append( new JButton('Button D')); _frame.getContentPane().append( new JButton('Button E')); _frame.getContentPane().append( new JButton('Button F')); _frame.getContentPane().append( new JButton('Button G')); _frame.getContentPane().append( new JButton('Button H')); getContentPane().append(_frame); _frame.show(); } private function updateLayout():Void { _frame.getContentPane().setLayout(_layout); } private function onHGapChanged(obj:Object):Void { var s:JSlider = JSlider(obj); _layout.setHgap(s.getValue()); updateLayout(); } private function onVGapChanged(obj:Object):Void { var s:JSlider = JSlider(obj); _layout.setVgap(s.getValue()); updateLayout(); } private function onRowsChanged( obj:Object):Void { var a:JAdjuster = JAdjuster(obj); _layout.setRows(a.getValue()); updateLayout(); } private function onColsChanged(obj:Object):Void { var a:JAdjuster = JAdjuster(obj) _layout.setColumns(a.getValue()); updateLayout(); trace(_layout); } }
| Print article | This entry was posted by motoki on 11月 17, 2007 at 9:04 pm, and is filed under ASwing, ActionScript. Follow any responses to this post through RSS 2.0. You can leave a response or trackback from your own site. |
about 1 year ago
「別ける」ってなんじゃ?