haphazard events

I have a requirement to open another window as soon as the user closes the current window.

We are using a framework and extending a framework class(Abstract Frane) to create new frames. The abstract frame adds defautl internal frame listerner to the created window. And also there is a toolbar in desktop pane.

As per my requirement, i have added a new internal frame listener and has code to invoke a new screen in the internal frame closed event.Now there two internal frame listeners 1) Added by frame work 2) Explicitly added by me.

When the window is closed, the code that i wrote in internalframeclosed event is getting executed and the next scteen is invoked, Now the problem is here. Next, the listener added by framework fires and it has code to disable the tool bar . so the tool bar is getting disabled. But actually the bar always point to current frame. so, it's setting should confrom to newly opened frame. As the infterframe closed event is firing after the new window is created, tool bar is becoming non funtional. As per my knowledge there is noway impose sequence on the events. I have some functionality in the listerner added by framework and as far as possible don't want it to be removed.

Is there any way to control this.

[1280 byte] By [psp_prasada] at [2007-10-1 6:51:19]
# 1

Hi,

There's a method getListeners()

that returns an array of all listeners assigned to this component. You can accompilish your job using these steps

1- Get an array of all listeners assigned to the frame.

2- Determine the listener that causes the problem.

3- Create a new listener that calls the old listener (the one causing the problem), then it will recover the problems caused by it. (Enable the toolbar in your case).

4- Remove the old listener using the appropriate removeXXXListener then add your new listener using addXXXListener.

I hope these steps were clear and they solve the problem.

--

Regards,

Ahmed Saad

Ahmed.Saada at 2007-7-9 17:19:24 > top of Java-index,Archived Forums,Java 2 Software Development Kit (J2SE SDK)...
# 2

This is kind of hacky but you could encopass the offending listener code in an invokeLater():

SwingUtilities.invokeLater(new Runnable()

{

public void run()

{

// Listener code here.

}

});

That would cause it to be executed after all of the other events you get. Not the best of solutions but it should work in this case.

Cheers,

Kevan.

TheMoncha at 2007-7-9 17:19:24 > top of Java-index,Archived Forums,Java 2 Software Development Kit (J2SE SDK)...
# 3
hi kevan, i tried u'r solution and it worked. Assigned Duke dollars.Ahmed ,thanks for response. regards,prasad
psp_prasada at 2007-7-9 17:19:24 > top of Java-index,Archived Forums,Java 2 Software Development Kit (J2SE SDK)...
# 4
No problem Prasad - glad I could help.
TheMoncha at 2007-7-9 17:19:24 > top of Java-index,Archived Forums,Java 2 Software Development Kit (J2SE SDK)...