home *** CD-ROM | disk | FTP | other *** search
Java Source | 2000-05-04 | 8.3 KB | 257 lines |
- import com.ms.wfc.app.*;
- import com.ms.wfc.core.*;
- import com.ms.wfc.ui.*;
-
- import java.util.Date ;
- import SimpComp.* ;
-
- /**
- * TestControlForm
- *
- * A form to test the SimpleControl
- *
- * The form hosts the control as a WFC Control - not as an ActiveX Control
- * and allows various control properties to be set.
- *
- * It also hooks events from the control
- *
- */
- public class TestControlForm extends Form {
- /**
- * Initialise the form - called when the application is run
- */
- public TestControlForm() {
- super();
-
- // Required for Visual J++ Form Designer support
- initForm();
- }
-
- /**
- * Part of the demo/sample interface, this retrieves the HTML help text for
- * the sample.
- */
- public String getHTML() {
- return "";
- }
-
- /**
- * TestControlForm overrides dispose so it can clean up the
- * component list.
- */
- public void dispose() {
- super.dispose();
- components.dispose();
- }
-
- /*
- * This methods hooks to the changed event on the edit control
- * feeding text into SimpleControl
- */
- private void sleStringData_textChanged(Object source, Event e) {
- simpleControl1.setStringData (((Edit)source).getText()) ;
- }
-
- /*
- * This methods hooks to the number data changed event that is fired
- * by SimpleControl whenever the numberDataProperty is changed. It sets
- * the value of the label control to the value of the SimpleControl
- * numberData property
- */
- private void simplecontrol1_numberDataChanged(Object source, Event e) {
- short numberValue = ((SimpleControl)source).getNumberData() ;
- String textValue = (new Short(numberValue)).toString() ;
- lblNumberValue.setText(textValue) ;
- }
-
- /*
- * This methods hooks to the click event for the Angry radiobutton
- * It sets SimpleControl to Angry mode
- */
- private void rbAngry_click(Object source, Event e) {
- simpleControl1.setDrawingMode(DrawingMode.ANGRY) ;
- }
-
- /*
- * This methods hooks to the click event for the Calm radiobutton
- * It sets SimpleControl to Calm mode
- */
- private void rbCalm_click(Object source, Event e) {
- simpleControl1.setDrawingMode(DrawingMode.CALM) ;
- }
-
- /*
- * This methods hooks to the click event for the Awkward radiobutton
- * It sets SimpleControl to Awkward mode
- */
- private void rbAwkward_click(Object source, Event e) {
- simpleControl1.setDrawingMode(DrawingMode.AWKWARD) ;
- }
-
- /*
- * This methods hooks to the click event for the Set Number Data button
- * It sets the numberData property of SimpleControl to the time now
- * as seconds
- */
- private void butSetNumberData_click(Object source, Event e) {
- Date now = new Date() ;
- long secs = now.getTime() ;
- simpleControl1.setNumberData((short)secs) ;
- }
-
- private void rbCalm_checkedChanged(Object source, Event e)
- {
-
- }
-
- /**
- * NOTE: The following code is required by the Visual J++ form
- * designer. It can be modified using the form editor. Do not
- * modify it using the code editor.
- */
- Container components = new Container();
- SimpleControl simpleControl1 = new SimpleControl();
- Edit sleStringData = new Edit();
- Label label1 = new Label();
- RadioButton rbAngry = new RadioButton();
- Button butSetNumberData = new Button();
- Label lblNumberValue = new Label();
- GroupBox groupBox1 = new GroupBox();
- GroupBox groupBox2 = new GroupBox();
- RadioButton rbCalm = new RadioButton();
- RadioButton rbAwkward = new RadioButton();
- GroupBox groupBox3 = new GroupBox();
- GroupBox groupBox4 = new GroupBox();
-
- private void initForm()
- {
- this.setText("TestControlForm");
- this.setAutoScaleBaseSize(new Point(5, 13));
- this.setClientSize(new Point(617, 244));
-
- simpleControl1.setAnchor(ControlAnchor.ALL);
- simpleControl1.setLocation(new Point(28, 30));
- simpleControl1.setSize(new Point(223, 182));
- simpleControl1.setTabIndex(4);
- simpleControl1.setTabStop(false);
- simpleControl1.setText("simpleControl1");
- simpleControl1.setDrawingMode(DrawingMode.CALM);
- simpleControl1.setNumberData((short)102);
- simpleControl1.setStringData("sdfsdf");
- simpleControl1.setMyOwnType(MyOwnType.TYPE1);
- simpleControl1.addOnNumberDataChanged(new EventHandler(this.simplecontrol1_numberDataChanged));
-
- sleStringData.setAnchor(ControlAnchor.TOPRIGHT);
- sleStringData.setLocation(new Point(381, 31));
- sleStringData.setSize(new Point(200, 20));
- sleStringData.setTabIndex(0);
- sleStringData.setText("");
- sleStringData.addOnTextChanged(new EventHandler(this.sleStringData_textChanged));
-
- label1.setAnchor(ControlAnchor.TOPRIGHT);
- label1.setLocation(new Point(309, 28));
- label1.setSize(new Point(64, 16));
- label1.setTabIndex(6);
- label1.setTabStop(false);
- label1.setText("String Data");
-
- rbAngry.setAnchor(ControlAnchor.BOTTOMLEFT);
- rbAngry.setBackColor(Color.CONTROL);
- rbAngry.setLocation(new Point(16, 64));
- rbAngry.setSize(new Point(85, 25));
- rbAngry.setTabIndex(2);
- rbAngry.setText("Angry");
- rbAngry.addOnClick(new EventHandler(this.rbAngry_click));
-
- butSetNumberData.setAnchor(ControlAnchor.TOPRIGHT);
- butSetNumberData.setLocation(new Point(429, 66));
- butSetNumberData.setSize(new Point(144, 88));
- butSetNumberData.setTabIndex(2);
- butSetNumberData.setText("Change the number");
- butSetNumberData.addOnClick(new EventHandler(this.butSetNumberData_click));
-
- lblNumberValue.setAnchor(ControlAnchor.TOPRIGHT);
- lblNumberValue.setBackColor(Color.INFO);
- lblNumberValue.setFont(new Font("Arial", 12.0f, FontSize.POINTS, FontWeight.BOLD, false, false, false, CharacterSet.DEFAULT, 0));
- lblNumberValue.setLocation(new Point(327, 200));
- lblNumberValue.setSize(new Point(232, 24));
- lblNumberValue.setTabIndex(7);
- lblNumberValue.setTabStop(false);
- lblNumberValue.setText("");
- lblNumberValue.setTextAlign(HorizontalAlignment.CENTER);
-
- groupBox1.setAnchor(ControlAnchor.ALL);
- groupBox1.setLocation(new Point(12, 6));
- groupBox1.setSize(new Point(263, 222));
- groupBox1.setTabIndex(3);
- groupBox1.setTabStop(false);
- groupBox1.setText("Control");
-
- groupBox2.setAnchor(ControlAnchor.TOPRIGHT);
- groupBox2.setLocation(new Point(293, 7));
- groupBox2.setSize(new Point(304, 168));
- groupBox2.setTabIndex(1);
- groupBox2.setTabStop(false);
- groupBox2.setText("Set the control properties");
-
- rbCalm.setAnchor(ControlAnchor.BOTTOMLEFT);
- rbCalm.setBackColor(Color.CONTROL);
- rbCalm.setLocation(new Point(16, 16));
- rbCalm.setSize(new Point(85, 25));
- rbCalm.setTabIndex(0);
- rbCalm.setTabStop(true);
- rbCalm.setText("Calm");
- rbCalm.setChecked(true);
- rbCalm.addOnClick(new EventHandler(this.rbCalm_click));
- rbCalm.addOnCheckedChanged(new EventHandler(this.rbCalm_checkedChanged));
-
- rbAwkward.setAnchor(ControlAnchor.BOTTOMLEFT);
- rbAwkward.setBackColor(Color.CONTROL);
- rbAwkward.setLocation(new Point(16, 40));
- rbAwkward.setSize(new Point(85, 25));
- rbAwkward.setTabIndex(1);
- rbAwkward.setText("Awkward");
- rbAwkward.addOnClick(new EventHandler(this.rbAwkward_click));
-
- groupBox3.setAnchor(ControlAnchor.BOTTOMLEFT);
- groupBox3.setLocation(new Point(16, 56));
- groupBox3.setSize(new Point(104, 104));
- groupBox3.setTabIndex(0);
- groupBox3.setTabStop(false);
- groupBox3.setText("I am:");
-
- groupBox4.setAnchor(ControlAnchor.TOPRIGHT);
- groupBox4.setLocation(new Point(295, 184));
- groupBox4.setSize(new Point(304, 48));
- groupBox4.setTabIndex(5);
- groupBox4.setTabStop(false);
- groupBox4.setText("Hooked to Number Change Event");
-
- this.setNewControls(new Control[] {
- lblNumberValue,
- butSetNumberData,
- label1,
- sleStringData,
- simpleControl1,
- groupBox1,
- groupBox2,
- groupBox4});
- groupBox2.setNewControls(new Control[] {
- groupBox3});
- groupBox3.setNewControls(new Control[] {
- rbAngry,
- rbAwkward,
- rbCalm});
- }
-
- /**
- * The main entry point for the application.
- *
- * @param args Array of parameters passed to the application
- * via the command line.
- */
- public static void main(String args[]) {
- Application.run(new TestControlForm());
- }
- }
-