NewDialog.java

/*******************************************************************
NewDialog.java
This sample is provided as a companion to the Introduction to WFC 
Programming topic in the Visual J++ documentation. Read the section 
titled MyNotepad Sample Walkthrough in conjunction with this sample.

This form represents a simple modal dialog box.

********************************************************************/ 


import com.ms.wfc.app.*;
import com.ms.wfc.core.*;
import com.ms.wfc.ui.*;

public class NewDialog extends Form
{

    public NewDialog()
    {
        // Required for Visual J++ Forms Designer support
        initForm();     
    }

    /**
     * NOTE: The following code is required by the Visual J++ Forms
     * Designer. It can be modified using the Form editor. Do not
     * modify it using the Text editor.
     */

    Container components = new Container();
    Label label1 = new Label();
    Label label2 = new Label();
    Button yesButton = new Button();
    Button noButton = new Button();
    Button cancelButton = new Button();
    PictureBox pictureBox1 = new PictureBox();

    private void initForm()
    {
        // NOTE:  This form is storing resource information in an
        // external file. Do not modify the string parameter to any
        // resources.getObject() function call. For example, do not
        // modify "foo1_location" in the following line of code
        // even if the name of the Foo object changes: 
        // foo1.setLocation((Point)resources.getObject("foo1_location"));

        IResourceManager resources = new 
           ResourceManager(this, "NewDialog");
        label1.setLocation(new Point(90, 20));
        label1.setSize(new Point(210, 20));
        label1.setTabIndex(0);
        label1.setTabStop(false);
        label1.setText("The text in the file may have changed.");

        label2.setLocation(new Point(90, 40));
        label2.setSize(new Point(190, 20));
        label2.setTabIndex(1);
        label2.setTabStop(false);
        label2.setText("Do you want to save the changes?");

        yesButton.setLocation(new Point(20, 90));
        yesButton.setSize(new Point(80, 30));
        yesButton.setTabIndex(2);
        yesButton.setText("&Yes");
        yesButton.setDialogResult(DialogResult.YES);

        noButton.setLocation(new Point(110, 90));
        noButton.setSize(new Point(80, 30));
        noButton.setTabIndex(3);
        noButton.setText("&No");
        noButton.setDialogResult(DialogResult.NO);

        cancelButton.setLocation(new Point(200, 90));
        cancelButton.setSize(new Point(80, 30));
        cancelButton.setTabIndex(4);
        cancelButton.setText("&Cancel");
        cancelButton.setDialogResult(DialogResult.CANCEL);

        this.setText("MyNotepad");
        this.setAcceptButton(yesButton);
        this.setAutoScaleBaseSize(13);
        this.setCancelButton(cancelButton);
        this.setClientSize(new Point(297, 136));

        pictureBox1.setLocation(new Point(20, 20));
        pictureBox1.setSize(new Point(50, 50));
        pictureBox1.setTabIndex(5);
        pictureBox1.setTabStop(false);
        pictureBox1.setText("");
         
        pictureBox1.setImage((Bitmap)resources.getObject
            ("pictureBox1_image"));

        this.setNewControls(new Control[] {
                            pictureBox1, 
                            cancelButton, 
                            noButton, 
                            yesButton, 
                            label2, 
                            label1});
    }

}