form survives and reappears after dispose???

T

timasmith

I have a form with an 'add' button which creates a new dialog with a
panel to add new data and an ok or cancel which both call dispose();

The code is something *similar* to the example below.

The wierd part is when I click on the cmdAdd button again - it does not
create a new dialog rather it shows the old dialog with a panel filled
out with my data contents! It is fixed if I dispose the originating
dialog (not desired).

Not very helpful and quite strange. I cant help wondering if it is the
use of 'final' below which I use to get a reference from within the
ActionListener

Any ideas?


cmdAdd.addActionListener(new UIActionListener(frame) {
public void actionExecuted(ActionEvent e) throws Exception {
final MyDialog dialog = new MyDialog(frame);
dialog.getCancelButton.addActionListener(new
UIActionListener(frame) {
public void actionExecuted(ActionEvent e) throws Exception {
dialog.dispose();
}
});
dialog.getAddButton().addActionListener(new MyActionListener(frame)
{
public void actionExecuted(ActionEvent e) throws Exception {
MyServices.updateDate(addDataModel);
myList.setList(getReferenceList(), 60);
dialog.dispose();
};
});
 
S

steve

I have a form with an 'add' button which creates a new dialog with a
panel to add new data and an ok or cancel which both call dispose();

The code is something *similar* to the example below.

The wierd part is when I click on the cmdAdd button again - it does not
create a new dialog rather it shows the old dialog with a panel filled
out with my data contents! It is fixed if I dispose the originating
dialog (not desired).

Not very helpful and quite strange. I cant help wondering if it is the
use of 'final' below which I use to get a reference from within the
ActionListener

Any ideas?


cmdAdd.addActionListener(new UIActionListener(frame) {
public void actionExecuted(ActionEvent e) throws Exception {
final MyDialog dialog = new MyDialog(frame);
dialog.getCancelButton.addActionListener(new
UIActionListener(frame) {
public void actionExecuted(ActionEvent e) throws Exception {
dialog.dispose();
}
});
dialog.getAddButton().addActionListener(new MyActionListener(frame)
{
public void actionExecuted(ActionEvent e) throws Exception {
MyServices.updateDate(addDataModel);
myList.setList(getReferenceList(), 60);
dialog.dispose();
};
});

you need to read up on the java.
Dispose, does not do what you think it does.

you could try :
dialog.dispose();
dialog=null;
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top