首先看效果:二话不说看图:
附件:
回答题.swf然后是两个类文件。- package {
- import org.aswing.*;
- import org.aswing.border.*;
- import org.aswing.geom.*;
- import org.aswing.colorchooser.*;
- import org.aswing.ext.*;
- /**
- * MyPanel
- */
- public class MyPanel extends JPanel{
-
- //members define
- private var label7:JLabel;
- private var label10:JLabel;
- private var myTextArea:JTextArea;
- private var myBtn:JButton;
-
- /**
- * MyPanel Constructor
- */
- public function MyPanel(){
- //component creation
-
- setOpaque(true);
- setBackground(new ASColor(0xeeeeee));
-
- setSize(new IntDimension(400, 151));
- var border0:CaveBorder = new CaveBorder();
- border0.setBeveled(true);
- setBorder(border0);
- var layout1:FlowLayout = new FlowLayout();
- setLayout(layout1);
-
- label7 = new JLabel();
- label7.setFont(new ASFont("Tahoma", 14, true, false, false, false));
- label7.setLocation(new IntPoint(5, 5));
- label7.setSize(new IntDimension(244, 21));
- label7.setText("阅读课文内容后请回答下面的问题:");
-
- label10 = new JLabel();
- label10.setOpaque(false);
- label10.setLocation(new IntPoint(5, 31));
- label10.setSize(new IntDimension(174, 23));
- var border2:CaveBorder = new CaveBorder();
- border2.setBeveled(true);
- label10.setBorder(border2);
- label10.setText("1.唐朝对东突厥做了那些政策?");
-
- myTextArea = new JTextArea();
- myTextArea.setLocation(new IntPoint(23, 5));
- myTextArea.setSize(new IntDimension(391, 67));
- myTextArea.setText("答:包括战争,唐太宗借东突厥内乱之机扫平东突厥;唐朝政府在当地设立都督府,任用突厥贵族进行管理;保留原有的民族习惯与生活方式");
- myTextArea.setWordWrap(true);
- myTextArea.setOpaque(true);
- myTextArea.setBackground(new ASColor(0xdddddd));
-
- myBtn = new JButton();
- myBtn.setLocation(new IntPoint(5, 71));
- myBtn.setSize(new IntDimension(58, 26));
- myBtn.setText("显示答案");
-
- //component layoution
- append(label7);
- append(label10);
- append(myTextArea);
- append(myBtn);
-
- }
-
- //_________getters_________
-
-
-
- public function getMyTextArea():JTextArea{
- return myTextArea;
- }
-
- public function getMyBtn():JButton{
- return myBtn;
- }
-
-
- }
- }
复制代码 第二类文件,文档类。- package
- {
- import Flash.display.Sprite;
- import flash.events.Event;
- import flash.events.MouseEvent;
- import org.aswing.AsWingManager;
- import org.aswing.geom.IntPoint;
- import org.aswing.JButton;
- import org.aswing.JLabel;
- import org.aswing.JTextArea;
-
- /**
- * ...
- * @author yuxuan2658
- */
- public class Main extends Sprite
- {
- //private var mylabel:JLabel;
- private var isShowing:Boolean;
- private var mytextarea:JTextArea;
- private var mybutton:JButton;
-
- public function Main():void
- {
- if (stage) init();
- else addEventListener(Event.ADDED_TO_STAGE, init);
- }
-
- private function init(e:Event = null):void
- {
- removeEventListener(Event.ADDED_TO_STAGE, init);
- // entry point
-
- AsWingManager.initAsStandard(this);
-
- var myp:MyPanel = new MyPanel();
- addChild(myp);
- myp.setSizeWH(400, 151);
- myp.validate();
-
-
- mybutton = myp.getMyBtn() as JButton;
- //addChild(mybutton);
- //mybutton.setSizeWH(60,25);
- mybutton.addEventListener(MouseEvent.CLICK, onClicked);
-
- mytextarea = myp.getMyTextArea() as JTextArea;
-
- mytextarea.setVisible(false);
- isShowing = true;
- }
-
- private function onClicked(e:MouseEvent):void
- {
-
-
-
- if (isShowing) {
-
- mytextarea.setVisible(true);
- mybutton.setText("隐藏答案");
-
- }else{
-
- mytextarea.setVisible(false);
- mybutton.setText("显示答案");
-
- };
-
- isShowing = !isShowing;
-
- //trace(isShowing);
- }
-
- }
-
- }
复制代码 说明一下:本课件用flashdevelop+aswing做成。
|