Click to See Complete Forum and Search --> : Dialog


sat
August 13th, 1999, 05:53 AM
Hello Friends

I'm writing a wrapper class MyWrapper for dialog.I have TextFiled , OK Button and Cancel Button on MyDialog. the wrapper class returns Textfield value by function getTextfieldValue().and wrapper class also has a function showDialog() function.

I'm Using this wrapper class in another Pprogram i.e Myanother() extends Frame. This has a button1 on this. If I press button1:
1)I'm Creating a Wrapper class.
MyWrapper wrap = new MyWraper();
2) then, I'm calling s
wrap.showDialog();
now i'll get MYDialog on the screen.
3) here i entered "APPLE" in text field.
4) To get Text field value ,
I can use Wrapper class function
String str = wrap.getTextFieldValue();
But I want to get this value , if user presses OK button on My Dialog.
But, How Myanother Program (i.e External Program ) Knows User pressed OK Button. If User Presses OK Button on My Dialog, Then Only I have to use the Function getTextFieldValue().

Q1)But How External program knows that User pressed OK Button.

Q2)If i write a bean to this wrapper, how to raise event and inform to external program that, user has pressed OK Button??

Please clarify my doubt...

Regards
sat

poochi
September 21st, 1999, 03:16 PM
Have one member variable and two constants in your Wrapper Class..

// Variable

public int nID = 0;

// Constants

public final static ID_OK = 1;
public final static ID_CANCEL = 2;

and in your button click action listener , set the appropriate values to
nID.

if ( "OK button clicked" ){
nID = ID_OK
}else( "Cancel button clicked" ){
nID = ID_CANCEL
}


and in your client side , do like this

WrapperClass myWrapper = new WrapperClass();
myWrapper.show();

if( myWrapper.nID == WrapperClass.ID_OK ){
// do your stuff here...
}

Have a good day..

Poochi