在flex项目中调用aswing组件

附件:
asWing.swc

示例一:



import mx.core.UIComponent;
import org.aswing.*;
private var s:Sprite=new Sprite();
private function initApp(){
AsWingManager.initAsStandard(this);
var comp:UIComponent=new UIComponent();
var frame:JFrame=new JFrame(comp,"哈哈");
frame.setSizeWH(300,300);
frame.setDragable(true);
frame.setResizable(true);
frame.show();
container.addChild(comp);
}

]]>






示例二:






import org.aswing.EmptyLayout;
import org.aswing.JPanel;
import org.aswing.JButton;
import org.aswing.AsWingManager;

public var panel:JPanel = new JPanel(new EmptyLayout());
public function init():void
{
mybtn1.addEventListener(MouseEvent.CLICK,clickbt1);
mybtn2.addEventListener(MouseEvent.CLICK,clickbt2);
AsWingManager.setRoot(mylabel);
panel.setSizeWH(200,100);
mylabel.addChild(panel);
panel.x=100;
panel.y=100;
//this.addEventListener(KeyboardEvent.KEY_DOWN,keyHandler);
AsWingManager.setRoot(this.parent);
AsWingManager.updateAfterMilliseconds(0);

}

public function clickbt1(evt:MouseEvent):void
{
if(panel.numChildren==2)
panel.removeChildAt(1);
var jb:JButton = new JButton("button--1");
jb.width=100;
jb.height=20;
panel.addChild(jb);
panel.revalidate();
trace(panel.numChildren);
}
public function clickbt2(evt:MouseEvent):void
{
trace(panel.numChildren);

if(panel.numChildren==2)
panel.removeChildAt(1);
var jb:JButton = new JButton("button--2");
jb.width=100;
jb.height =20;
panel.addChild(jb);
panel.revalidate();


}
]]>

你可能感兴趣的:(Flex,XML)