yourJPanel.setBackgroundDecorator(new AssetBakcground(yourImage));
package
{
import flash.display.DisplayObject;
import flash.display.Sprite;
import flash.events.Event;
import flash.events.MouseEvent;
import flash.filters.DropShadowFilter;
import flash.geom.Rectangle;
import org.aswing.*;
import org.aswing.border.EmptyBorder;
public class PanelBg extends Sprite{
[Embed(source="icon5.png")]
private var imgClass:Class;
private var window:JWindow;
public function PanelBg()
{
super();
AsWingManager.initAsStandard(this);
window = new JWindow();
var img:DisplayObject = new imgClass() as DisplayObject;
img.filters = [new DropShadowFilter()];
//make some blank space leave to the img shadow
window.setBorder(new EmptyBorder(null, new Insets(0, 0, 4, 4)));
window.setBackgroundDecorator(new AssetBackground(img));
//or even you can directly call addChild to append a image
//window.addChild(img);
var buttonPane:JPanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
buttonPane.appendAll(new JButton("OK"), new JButton("Cancel"));
window.getContentPane().append(buttonPane, BorderLayout.SOUTH);
window.getContentPane().append(new JLabel("This is a JWindow"), BorderLayout.CENTER);
window.setSizeWH(300, 300);
window.show();
//simplly make the window dragable
window.addEventListener(MouseEvent.MOUSE_DOWN, __mouseDown);
window.addEventListener(MouseEvent.MOUSE_UP, __mouseUp);
}
private function __mouseDown(e:Event):void{
window.startDrag(false, new Rectangle(0, 0, stage.stageWidth, stage.stageHeight));
}
private function __mouseUp(e:Event):void{
window.stopDrag();
}
}
}