MENSAJES CON CLASE

`

 

``````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````

Clase Jdirect.java

 

import com.ms.wfc.app.*;

import com.ms.wfc.core.*;

import com.ms.wfc.ui.*;

import com.ms.wfc.html.*;

/**

* Esta clase puede tomar un nœmero variable de par‡metros en la l’nea de

 * de comandos. La ejecuci—n del programa comienza con el mŽtodo main(). El

 * constructor de clase no se invoca a menos que se cree un objeto del tipo

 * 'JDirect' en el mŽtodo main().

 */

public class JDirect extends Form

{

                public JDirect()

                {

                               super();

                               // Necesario para el soporte de Visual J++ Form Designer

                               initForm();                           

                               // TODO: Agregar cualquier c—digo de constructor despuŽs de la llmada initForm

                }

                /**

                 * JDirect omite la colocaci—n, por lo que puede limpiar la

                 * lista de componentes.

                 */

                public void dispose()

                {

                               super.dispose();

                               components.dispose();

                }

                private void btnShow_click(Object source, Event e)

                {

                               String msg;

                               msg = edtMessage.getText() + "\n\nÀDesea continuar?";

                               if(Win32.MessageBox(

                                               this.getHandle(), msg, edtCaption.getText(), Win32.MB_YESNO)

                                               == Win32.IDNO)

                               {

                                               Application.exit();

                               }

                }

                /**

                 * NOTA: El siguiente c—digo es necesario para el dise–ador de formularios

                 * de Visual J++. Puede modificarse editor de formularios. No lo

                 * modifique utilizando el editor de c—digo.

                 */

                Container components = new Container();

                Button btnShow = new Button();

                Label label1 = new Label();

                Edit edtMessage = new Edit();

                Label label2 = new Label();

                Edit edtCaption = new Edit();

                private void initForm()

                {

                               this.setText("J/Direct Message Box");

                               this.setAutoScaleBaseSize(new Point(5, 13));

                               this.setClientSize(new Point(262, 144));

                               btnShow.setLocation(new Point(96, 112));

                               btnShow.setSize(new Point(75, 23));

                               btnShow.setTabIndex(4);

                               btnShow.setText("Mostrar");

                               btnShow.addOnClick(new EventHandler(this.btnShow_click));

                               label1.setLocation(new Point(8, 8));

                               label1.setSize(new Point(56, 16));

                               label1.setTabIndex(0);

                               label1.setTabStop(false);

                               label1.setText("Mensaje:");

                               edtMessage.setLocation(new Point(8, 24));

                               edtMessage.setSize(new Point(248, 20));

                               edtMessage.setTabIndex(1);

                               edtMessage.setText("Esto es un mensaje");

                               label2.setLocation(new Point(8, 56));

                               label2.setSize(new Point(80, 16));

                               label2.setTabIndex(2);

                               label2.setTabStop(false);

                               label2.setText("Captura:");

                               edtCaption.setLocation(new Point(8, 72));

                               edtCaption.setSize(new Point(248, 20));

                               edtCaption.setTabIndex(3);

                               edtCaption.setText("Caption");

                               this.setNewControls(new Control[] {

                                                                                                              edtCaption,

                                                                                                              label2,

                                                                                                              edtMessage,

                                                                                                              label1,

                                                                                                              btnShow});

                }

                /**

                 * Punto de entrada principal para la aplicaci—n.

                 *

                 * @param args Matriz de par‡metros pasados a la aplicaci—n

                 * mediante la l’nea de comandos.

                 */

                public static void main(String args[])

                {

                               Application.run(new JDirect());

                }

}

````````````````````````````````````````````````````````````````````````````````````````````````````````````````````

 

Clase Win32.java

 

public class Win32

{

                /**

                 * @dll.import("USER32", auto)

                 */

                public static native int MessageBox(int hWnd, String lpText, String lpCaption, int uType);

                public static final int MB_YESNO = 0x00000004;

                public static final int IDNO = 7;

                public static final int IDYES = 6;

}