Link to home
Start Free TrialLog in
Avatar of jkteater
jkteaterFlag for United States of America

asked on

Changing a value from a method

when I open my dialog I am checking to make sure that it is the only dialog open using a IF

if (flag == 0) {
	    showediDialog(theSession);
	}
	return null;
	}

Open in new window


In the dialog method I am changing the value of flag

private void showediDialog(TCSession theSession) {
	   flag = 1; 
	   EdiBaseDialog ar = new EdiBaseDialog(null, theSession);
		 ar.setLocationRelativeTo(null); 
		 ar.setModal(false);
		 ar.setVisible(true);
   }    

Open in new window


Then I have written a small method to change the value back to 0

public int dialogCheck() {
	   flag = 0;
	   return flag;
   }

Open in new window


In my Cancel button I have this

 cancelButton.addActionListener(new ActionListener() {
         public void actionPerformed(ActionEvent e) {
        	 edh = new EdiDialogHandler();
        	 edh.dialogCheck();
        	 dispose();
         }
      });

Open in new window


Everything works except the cancel button don't seem to change the value of flag - where is the logic gone wrong?
Avatar of for_yan
for_yan
Flag of United States of America image

are you calling this dialogCheck ?
put System.out.println("chab=nging flag");
next to flag = 0;'


You don't need to have flag to make sure you have only one dialog

Make the dilaog hande itself, I guess "ar" in you code instance variable

at the top of the class:
 EdiBaseDialog   ar;

in method:
if(ar == null) ar =   new EdiBaseDialog(null, theSession);
meybe you'll need a method in this original class when you dispose of the dialog to set
ar to null. I think it wil even do it itself, but it is safer to have.
Still it is better than to have a flag

 
Avatar of jkteater

ASKER

You are correct that does keep it to 1 dialog :)  but what call would I put in my cancel button to pretty much remove all the information in the dialog?  Right now if I close it and open it back it has the same information - which I am ok with that, but I want the cancel button to remove everything so when the it is opened again it will be blank
you just make er = null before you dispose of it - and then all information is effectively gone.
Next time you create it with constructor (new) it will be blank as the previous time.

You want it to be blank -as created new - correct ?


If you want to keep it and just make it invisible for seome time then you just make setVisible(false) and setVisdible(true)
 


I will try to make er = null before you dispose of it
And you should not be conccenred where is all the stuff that was drawing it
after you set it to null and dispose of it - eventually garbage collection will deal with it - but you should not worry this is jvm's business
I am not sure how I would make it NULL?  
maybe I do give me a second
I guess not
Here is my dialog call

 
private void showediDialog(TCSession theSession) {
	   if(ar == null) ar =   new EdiBaseDialog(null, theSession); 
	   //EdiBaseDialog ar = new EdiBaseDialog(null, theSession);
		 ar.setLocationRelativeTo(null); 
		 ar.setModal(false);
		 ar.setVisible(true);
   }    

Open in new window


Here is the code for the cancel button

EdiDialogHandler ar;

Open in new window


cancelButton.addActionListener(new ActionListener() {
         public void actionPerformed(ActionEvent e) {
        	ar = null;
        	 dispose();
         }
      });

Open in new window


What am I missing
do I need a method in the class that is calling the dialog that will change the ar value then call something like

ar.setNull(); in the cancel button?
yes

 setNull(){
ar = null;
}

should be called before disposing. before disposing

but itshould be invokled not on ar
but on instance of your class which contain all this code and method should be in this class  - in this same class wehere you create this dialog
This is what I have

cancelButton.addActionListener(new ActionListener() {
         public void actionPerformed(ActionEvent e) {
        	 edh = new EdiDialogHandler();
        	 edh.setNull();
        	dispose();
         }
      });

Open in new window



This method is in  EdiDialogHandler

public void setNull() {
      ar = null; 
   }

Open in new window


This method is in  EdiDialogHandler

private void showediDialog(TCSession theSession) {
	   if(ar == null) ar = new EdiBaseDialog(null, theSession); 
	   ar.setLocationRelativeTo(null); 
	   ar.setModal(false);
	   ar.setVisible(true);
   }    

Open in new window


THis is the rest of EdiDialogHandler

public class EdiDialogHandler extends AbstractHandler {
	 EdiBaseDialog ar;
	
	TCSession theSession = null;
	
	/* The constructor */
	public EdiDialogHandler() {
	}
    
	@Override
   public Object execute(final ExecutionEvent event) throws ExecutionException {
	  
	try {
		theSession = EdiInitialization.Initialize();
	} catch (TCException e) {
		e.printStackTrace();
	}
	   showediDialog(theSession);
		return null;
	}

Open in new window


Everything seems to work no errors - but it still opens with the data in the dialog already
Impossible
Post what you are doing in construictor
I put some print statements in

public void setNull() {
	   System.out.println("setNull : " + ar + "\n");
	   ar = null; 
   }

Open in new window


 private void showediDialog(TCSession theSession) {
	   System.out.println("show : " + ar + "\n");
	   if(ar == null) ar = new EdiBaseDialog(null, theSession); 
	   //EdiBaseDialog ar = new EdiBaseDialog(null, theSession);
		 ar.setLocationRelativeTo(null); 
		 ar.setModal(false);
		 ar.setVisible(true);
   }    

Open in new window


When I first open the dialog - prints "show null"
if I close the dialog without using cancel and open it up - print "show bunch of text"

So i know that ar is not null right now.

close the dialog using the cancel button - prints "setNull null"

So I would assume that ar is null

but when I open it again - prints  "show bunch of text"

It seems like the ar I am setting to null is not the same ar in the if check

constructor for where the dialog is called

public EdiDialogHandler() {
	}

Open in new window

constructor for the cancel button class

 
public EdiBaseDialog(Frame parent, TCSession theSession){
	   super(parent, false);
	   session = theSession;
	   myModel = SingletonSelectTable.getInstance();
	   myModel.setEdb(this);
	   
	   createDialog();  
   } //end Constructor

Open in new window

Avatar of CEHJ
>>
         public void actionPerformed(ActionEvent e) {
               edh = new EdiDialogHandler();
               edh.dialogCheck();
               dispose();
         }

>>

Make sure the variable you're calling 'flag' is the variable you think it is
e.g. if you're creating arbitrary numbers of dialogs, the only way that variable is going to work is if it persists across new instances of the dialogs. Normally it would be an instance variable of the class that's creating them
The reason why you are getting the same is because your myModel = SingletonSelectTable.getInstance() - is alaways the same
- so you ppopulated it with asome list of data - and it is still there - so it credates
new dialog and populateds it with the same data.
So before you go waay from you previous user/dialog - just where you cll settuing null youir dalog -
you should alos re-create the ArrayList whixch contains your previous data
I don't rememeber but you shou,ld have aList = new ArrayList<...>() at the very same point.
Then it will not be populated with stuff when you create a new dialog.
That;'s waht I'm guessing basdd on previous recollections
The question is why the flag doesn't change:

>>Everything works except the cancel button don't seem to change the value of flag - where is the logic gone wrong?
The data I am referring to is not the list data.  I am not even populating the list when I am testing it
So what can be left there?

You should understand that once you closed your dialog, said ar = null
and next time you are executing ar = new   EdiBaseDialog(null, theSession);
even though you have the same name "ar" in your code
the object you create has absolutely nothing to do with your prevuiius one
It just goes through all the code in your constructor and creates new ovbject
If it uses soem persistemt indformation - like underrlying
arrays or lists - and you have the singletomn instance of this model - which all
is still there - ththat would be reflected - but there is no remanants of your previous
object - whatever you see was createv anew with your constructor and even placed in different
placce in physical memor - does not matter that you have the saem variable naming it in your code.
If we can get back to the actual question, where is this variable 'flag' jkteater?
So you should forget about previous dialog and look at this code:

myModel = SingletonSelectTable.getInstance();
         myModel.setEdb(this);
        
         createDialog();

and try to understadn waht variables are you using here which still conain the old values
and populate your brand new dialog with the old  data - and you should re-create those
variables at the moment when you realize that you finshed working with the previous dialog/user ot whatever that old object is.
Varaible flag would not change anything.
If you are recreating the same dialog it hppens because when you creating
it you are relying on some old data.
Variable lag was only used for preventing to create new dialog if the old one exists - you can do it through flag or through
checking null on the dialog itself, but it re-creates the old dialog viewe beacuse underlying data it uses in cosntrcution of the dialog
were not cleared
So if in your createDialog() method you are using this myModel instance - rememeber that your
myModel is singleton - so with that
myModel = SingletonSelectTable.getInstance();
you are getting al the time the same instance - so whatever instance varibales your myModel had pervious time
class they will all be the same unless you reinitialized them.
So you need to re-initialize them at the moment when you want to start a new cycle/user/case.
jkteater, there's a lot of noise in this question. Can you please restate the problem? If you think it's changed for some reason, please say so
Basically when the user clicked the menu action to open the dialog, they could click it 3 times or more and 3 or more dialogs would will open up.  

I only want one dialog to be open, once the user is done with the dialog  I want them to click the cancel button and then when they click the menu again a new dialog opens with no data.

I had put a if statement in where the dialog is being called and that would stop having multiple dialogs, then i had a small method that changed the flag so when the if statement ran agiain after the user clicked the menu it would create a new dialog.  The method ran from the cancel button click.  But even though the prints out where saying that the method was changing the value, the if statement never seen the new value.  That is the issue pretty much in a nut shell
>>the if statement never seen the new value.  

So what happened when you investigated the nature/scope of 'flag' as i suggested?
But now you acheived that it does not allow you to open second wibndow while previous omne is opopene - correct?
So the issue is that you open second time the dialog - and it looks the same as the one you closed - is it corect status as of now?
show the place where calling method dialogCheck()
even though it really is not important anow abiut this flag, becuase checking for null on the
dialog itself is definitely no worse than introducing this flag
CEHJ - It still did not seem to change the value before the IF ran again. Unless I had it coded wrong which is possible

for_yan - It does not open a second dialog if the first one is opened, the status of the issue is when I click cancel and then click to open a new dialog, I need it to be empty, like the first time the dialog is created. RIght now data is still in it.
private JPanel OKCancelButtons() {
	  
	  
      JButton cancelButton = new JButton("Cancel");
      cancelButton.setEnabled(true);
      cancelButton.addActionListener(new ActionListener() {
         public void actionPerformed(ActionEvent e) {
        	 edh = new EdiDialogHandler();
        	 edh.setNull();
        	dispose();
         }
      });
            
      JPanel p = new JPanel();
      //p.setBorder(BorderFactory.createLineBorder(Color.red));
      p.setLayout(new BoxLayout(p, BoxLayout.LINE_AXIS));
      p.add(myModel.getButton());
      p.add(Box.createHorizontalGlue());
      p.add(myModel.getOKButton());
      p.add(cancelButton);

      return p;
   }// end OKCancelButtons()

Open in new window


CAlling this method
 public void setNull() {
	   System.out.println("setNull : " + ar + "\n");
	   ar = null; 
   }

Open in new window


I explained to you what may be the reason that you see the same dialog

Post your createDialog() method

and forget abot the flag - it is no longer relevant - we achieved the
result wfor which it was created with a better way
>>CEHJ - It still did not seem to change the value before the IF ran again. Unless I had it coded wrong which is possible

As i mentioned, the likelihood, if it's not changing the value, is that it's not the value you think it is. It needs to be a single GLOBAL variable for it to work
This is the whole class that creates the dialog when the user clicks a menu action


public class EdiDialogHandler extends AbstractHandler {
	 EdiBaseDialog ar;
	
	TCSession theSession = null;
	
	/* The constructor */
	public EdiDialogHandler() {
		
	}
    
	@Override
   public Object execute(final ExecutionEvent event) throws ExecutionException {
	  
	try {
		theSession = EdiInitialization.Initialize();
	} catch (TCException e) {
		e.printStackTrace();
	}
	   showediDialog(theSession);
		return null;
	}
   
   
   private void showediDialog(TCSession theSession) {
	   System.out.println("show : " + ar + "\n");
	   if(ar == null) ar = new EdiBaseDialog(null, theSession); 
	   //EdiBaseDialog ar = new EdiBaseDialog(null, theSession);
		 ar.setLocationRelativeTo(null); 
		 ar.setModal(false);
		 ar.setVisible(true);
   }    

   public void setNull() {
	   System.out.println("setNull : " + ar + "\n");
	   ar = null; 
   }

}
  

Open in new window

public void createDialog() {
	   
	  appReg = Registry.getRegistry(this);
	  setTitle(appReg.getString("edi.TITLE"));
	  	  
	  Component selectionsPanel = selectedTable();
	  Component currentPanel = currentItems();
	  Component buttonPanel = OKCancelButtons();
	  centerPanel = new JPanel();
      centerPanel.setLayout(new BoxLayout(centerPanel, BoxLayout.PAGE_AXIS));
      centerPanel.setPreferredSize(new Dimension(750, 350));
      centerPanel.add(Box.createRigidArea(new Dimension(5, 0)));
      centerPanel.add(currentPanel);
      centerPanel.add(selectionsPanel);
      centerPanel.add(Box.createHorizontalGlue());
      centerPanel.add(Box.createRigidArea(new Dimension(0, 2)));
      centerPanel.add(buttonPanel);
      
      getContentPane().add(centerPanel);
      
      addComponentListener(new ComponentAdapter() {
        public void componentResized(ComponentEvent event) {
           Component c = event.getComponent();
           c.setSize(Math.max((int)centerPanel.getPreferredSize().getWidth()/2, c.getWidth()),
                     Math.max((int)centerPanel.getPreferredSize().getHeight()/2, c.getHeight()));
        }
      });
       	  	
      this.pack();
      setLocation(getParent().getLocation(null));        
      centerPanel.setVisible(true);
    }// end createDialog()
   

Open in new window


what is EdiDialogHandler class ?

        edh = new EdiDialogHandler();
               edh.setNull();
              dispose();

you should not create it and then use it to setNull()
you should get to the same instance of your class from which you creted this dialog.
when you say
 edh = new EdiDialogHandler();
you create new uinsatnce and you change absolutely
different parameter
EdiDialogHandler is the class above that is creating the dialogs
We went with you already rthrough that many times

Let's start from the beginning - enumearte what classes you have once again -
and last time wwe atrted form that and I thought you understood that - lets start again

Enumaerate what classes you have an where you create your dialog and where you use it.
You should understand what is instance of the class and waht are insrtance variables and you should refer to the same instance not just arbirary create new ones
and execute methods on the new instances.
EdiDialogHandler - creates dialog
EdiBaseDialog - where the cancel button is

I thought I followed the steps pretty - but apparently not

This is a  total mess
You can;t possibly live with this stuff, for example with this:

  p.add(myModel.getButton());
      p.add(Box.createHorizontalGlue());
      p.add(myModel.getOKButton());

what is this? You are creating GUI interface - so how can you take buttons from some other class and add them
to panell in this class - this is not even possible to comprehend, what will be happneing with them and with their events, etc.

I think you should stop doing it - go to
very simple exmaple of how to create winodws, make interactions with the classes - understadn that
and then asatrt all your stuff from the very beginning

If you want, I can help you to get understanding - but we should do it with
the simple code to which we both have access - I posted you soem small application with
three woidnows - that would be one of the options.
 Once i see that you undnerstnd - then you'll be able to re-write your stuff in normal way.

Otherwise it goes nowhere. Just waste of the time.

So neither your flag, nor setNull() can possible work because you
are invoking these methods on a completely new instance which you just created.
and if you don;t undrstand  that, it means you still don't undesrtand
the very basic stuff.


And the issue is not following the steps - they will be always different in each situation - the issue
is to understand what you are doing.

You need to learn this. If I were you, I would follow my suggestion above.






p.add(myModel.getButton());<-- My buttons are created in a seperate class and if they are enabled or not is decided in that class.  Should I be doing

JButton ok = myModel.getButton();
p.add(ok);

I would love nothing more to be able to start over and recreate the code correctly, but the project I was given is way behind schedule and I am starting to catch much grief.  I can work on getting the code correct on the side, but I still have to hit deadlines with this code.  Once I get the above working, then this code is about 90% done.

Here is what I thought about instances

public A {
  public A {

  }
 
  public testA() {
  print "Hello";
  }

}


public B {
A t;

  public B {
  t = new a();
  }

print(t.testA());

}

I thought that was the way it worked?
I am guessing that the new is creating a new instance of A and that is why it is not working.

yes,  all GUI's should be created like that:

JButton ok = myModel.getButton();

p.add(ok);

and that should be mostly done in constructors
of the visual elemnts
You should never crete button in one class and pass it to anothe class -
maybe you can iimagine the situation when it would be justified
but the should be some mothsyears from now for you.

What you wrote about instances above does not sppeak at all about
interaction between classes and passingh handlers from one class to another of which we spoke a lot
and which is most importnat in your case (and almost in all java programs which has more than one class).

I still think it makes sense that you stop doing that ate least for couple odf days - sit down get a book or a tutorial -
and have 100% understandning what is instance of the class, what is instance variable, what is local variable,
what is static variable. How instance variabnles belong to instances of theier class.
Take a couple of simple code examples - understad how this interaction happens fully - so that
you'll not create a new instance invoke method in this new insatnce and then hope that it
would oaffect your original instance in which you creted theis dialog before
These kind of thing I believ eyou can undersatdn within a couple of days.

Then you should have minum understanding how to cretae visual elements
attach events to buttons/textfileds, etc
and how people normally split the creation of elements from
handiling the vents - look at some normals codes with this viwe.

When you get this understand maybe you will be able to deconvolute the most atrocious
coding which you see here and at least would stop wasting your time
asking questions like this one.

Otherwise - with some great luck you can suddenly make it working - but
then there will be next task, and next - and it will be pain all over if you do not internalize the very basics



 




>You should never crete button in one class and pass it to anothe class -
>maybe you can iimagine the situation when it would be justified

You can sometime pass a reference to button from one class to another
say in order to change the color of background of that original
button in the class that button was created from another class which nows when to change it,
even that is usually not vvery good practice
you should keep all these methods which change element appearances within the same class
where elements live and pass referebnce to this
class to your iothe classes so that you can acess these methods changing appearnces from events in
 other classes therough one handle of the class which has all these elements.

But what I meant above - is to grab "physical" button form another class
and  add it to panel in some othee  class - that is something really beyond normal
practice - and should never be done.

Actually you should stick to all elements creations to be done in the constructters of the class
and  methods and event hanldlers can modify their properties, but sually should not
create them.

Once I get this one working - I will take some time and create a simple project and and try to understand and learn how they relate and pass instances.  I just have to get this working first.  I will go ahead and change the buttons though
change the bttons
and make sure that you pass to that dialog which you create the refernce to the instance of the class wher it is
being created, say have in thad dilog
instabce varaible poointing to the instance variable of the type of the creator class
and pass it through the constructore.
then use this handle to setNull or to set flag uin the parent instnce
not in the one newly created.
write if you understodd that.

Here is the button location code

public EdiBaseDialog(Frame parent, TCSession theSession){
	   super(parent, false);
	   session = theSession;
	   myModel = SingletonSelectTable.getInstance();
	   myModel.setEdb(this);
	   submitButton = myModel.getOKButton();
	   removeButton = myModel.getButton();
	    createDialog();  
   } //end Constructo

Open in new window


Then I am doing p.add(removeButton);

I am going to walk through how I think this works - please bare with me


1.  
in EdiDialogHandler class upon execution I am calling this method

private void showediDialog(TCSession theSession) {
	   System.out.println("show : " + ar + "\n");
	   if(ar == null) ar = new EdiBaseDialog(null, theSession); 
	   //EdiBaseDialog ar = new EdiBaseDialog(null, theSession);
		 ar.setLocationRelativeTo(null); 
		 ar.setModal(false);
		 ar.setVisible(true);
   }    

Open in new window


because this is the first run ar is null, so ar is given a value by calling this assignemnt ar = new EdiBaseDialog(null, theSession);  - so now ar is the instance of the dialog and the EdiDialogHandler class.

2. I want to get the instance of ar to my EdiBaseClass

EdiDialogHandler edh;  <-- this is creating a variable edh of type EdiDialogHandler, but I still have not assigned any value to it.

3.

in the constructor I want to assign edh the value of ar.  I have tried many ways to do this.  
But I always go back to

edh = new EdiDialogHandler();

but apparently new is creating a new instance ar and we are not able to change the value I am looking to change.


4.  

In the cancel action I am calling a method in the creation class to change the ar instance value

public void actionPerformed(ActionEvent e) {
      	 
        	edh.setNull();
        	dispose();
         }

Open in new window



so I am thinking that step 3 is main problem?
ASKER CERTIFIED SOLUTION
Avatar of for_yan
for_yan
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
OK, right now fiorst of all read my previous post and write me if you undersatdn
100% everyrthing there and if you can now answer to yourself the question
why your flag was not changing before - we don't have flag here but the idology is the
same. . If you cannot understand it then  point to particular place or point which you don not
 understand.

this only addresses the interactions between these two classes

Why you get the new dialog populated with the old stuff - this is a separate issue, as i mentioned before.
>edh.nullEbd(); // and this points to exactly instance which created me, and in this way I disconnect
 >                      // from parent and from this pioint parent has no child and is allowed to create a new child

here I'm not invoking this method on some newly created dialog, I'm pointing to excatly that
instance that creted this very child; it is absolutwely critical that I'm using this very pointer that
was passed to me form parent in constructior as this; it points to particualar instance of my parent
not to some abstrct new instance of teh same type which I just created
OK, read attentively  my last three posts - acknowledge that you understand - then revise your prvious post - it is still not undrstandbale
The reason the flag was not working was because I was not getting the instance of the dialog when creating it - I was creating a new separate instance and two instance did not talk to each other.  That makes sense now.  When my dialog was being created, we now passed the instance value as it was being created.  Then we all we have to do was assigned the passed instance to a value in the constructor.

knowing this now, I can see how bad this question was.  It was a very simple thing and I made it so big.  

Do you still have that link to the sample project that you told me about a few questions ago.  I do need to work on this and I did say I would take a couple of days to go over it.  If not I will try and look through all the post and find it.

Thanks


It is in this post:
http://#36995063
No it does not work across questions - sorry it in post 36995063 but in question:

https://www.experts-exchange.com/questions/27405003/Java-Explain-Singleton.html
I reposted it here:

I would suggest that in a spare moment you look at this ismple example of how
classes intreact with each other - you can compile and see
how parent window intercats with childeren and chikldern with each other and look
at the ccode - in this cvase they represent framses - but this intercation throough
the handles between the classes in java application can work the same way between any classes,
not necessarily corresponding to visual elements
and it shows how in another class you can reach the same instance of some class
 which you creted in the third  class.

These things need to be understood clearly, then you'll be able to update
the table you created somewhere form another location in your application.
If you don't uinderstand this stuff, ask questions, it is really important.

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class MyMainWindow extends JFrame implements ActionListener {

      JTextField txt;
      JButton button;
      MyChildWindow child1;
      MyChildWindow child2;


    public MyMainWindow(){
        super("main");
     txt = new JTextField(10);
      button = new JButton("press");
        button.addActionListener(this);
            Container c = this.getContentPane();
        c.setLayout(new FlowLayout());
        c.add(txt);
        c.add(button);
          this.setSize(200,200);
        this.setLocation(100, 100);

      child1 = new MyChildWindow(this, 1);


           child2 = new MyChildWindow(this,2);


        child1.setVisible(true);
        child2.setVisible(true);
        this.setVisible(true);



    }
       public void setText(String s){
        txt.setText(s);
    }


    public void actionPerformed(ActionEvent e) {
            child1.setText(txt.getText());
          child2.setText(txt.getText());


    }

    public MyChildWindow getChild(int i){
        if(i==1)return child1;
        else return child2;
    }


    public static void main(String[] args) {
        new MyMainWindow();
    }


}

class MyChildWindow extends JFrame implements ActionListener {
    MyMainWindow parent;
       JTextField txt;
      JButton button;
    int num;

    public MyChildWindow(MyMainWindow parent, int num){
        super("child " + num );
        this.parent = parent;
        this.num = num;
           txt = new JTextField(10);
      button = new JButton("press");
           button.addActionListener(this);
        Container c = this.getContentPane();
          c.setLayout(new FlowLayout());
        c.add(txt);
        c.add(button);
        this.setSize(200,200);
        this.setLocation(num*200, num*200);

    }

    public void setText(String s){
        txt.setText(s);
    }

       public void actionPerformed(ActionEvent e) {
           parent.setText(txt.getText());
              MyChildWindow childNotMe = null;
           if(num == 1){
              childNotMe = parent.getChild(2);


           } else    childNotMe = parent.getChild(1);
           childNotMe.setText(txt.getText());



    }


}

Open in new window

As always thanks, I will start on this code in the morning
>>
The reason the flag was not working was because I was not getting the instance of the dialog when creating it - I was creating a new separate instance and two instance did not talk to each other.  That makes sense now.  
>>

(which is what i was telling you in the comments i posted. The 'flag' variable was not what you thought it was)