473,323 Members | 1,589 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,323 software developers and data experts.

Is it possible to use Nested Listeners?

I am writing a personal application that uses windowListeners,
ActionListeners and possible ItemListeners (combo boxes).

I have one of the Buttons (ActionListeners) set to have a popup
frame/panel to display a Choice. But I would like the Program to not
continue on until the user makes their selection from the
dropdown/Combo box in the new popup window.

Right now, I have it setup so that the Listeners for the main frame
are looking for the button clicks, and then depending on which is
clicked, it does whatever it has to do. But if the X-Button is
clicked, I wanted it to popup with that window and wait for a
selection to be made (a listener for a combo box).

Is this type of thing possible?

I tried having a flag set, and then just wait until that listener sets
the flag and records the choice. But the program runs too fast, and
the window doesnt pop up fast enough with its contents in order for it
to work.

I hope I made my question understandable. Ill post source if anyone
requests it. But its quite sloppy :) Thank in advance for any
responses on how I can accomplish this type of thing.
Jul 17 '05 #1
3 2627

"Rich Wahl" <ri*******@gmail.com> wrote in message
news:37**************************@posting.google.c om...
I am writing a personal application that uses windowListeners,
ActionListeners and possible ItemListeners (combo boxes).

I have one of the Buttons (ActionListeners) set to have a popup
frame/panel to display a Choice. But I would like the Program to not
continue on until the user makes their selection from the
dropdown/Combo box in the new popup window.

Right now, I have it setup so that the Listeners for the main frame
are looking for the button clicks, and then depending on which is
clicked, it does whatever it has to do. But if the X-Button is
clicked, I wanted it to popup with that window and wait for a
selection to be made (a listener for a combo box).

Is this type of thing possible?

I tried having a flag set, and then just wait until that listener sets
the flag and records the choice. But the program runs too fast, and
the window doesnt pop up fast enough with its contents in order for it
to work.

I hope I made my question understandable. Ill post source if anyone
requests it. But its quite sloppy :) Thank in advance for any
responses on how I can accomplish this type of thing.


You are not looking for nested listeners but nested message-loops instead.
Event driven GUI programs, including Swing programs and Win32 programs,
usually run around a message loop that looks like (extremely simplified
pseudo):

message-loop():
forever do
poll for an event like a mouse-click or key-stroke;
determine which window should receive the event;
pump the event through the registered listeners
end forever

to achieve what you want you would have an event listener (which is called
from inside a message loop already) call message-loop() itself. This is
usually combined with disabling all application windows already visible and
popping up a new one that will be covered by the nested loop.

In short, you want a modal window. Look at JDialog...

Silvio Bierman
Jul 17 '05 #2
"Silvio Bierman" <sb******@idfix.nl> wrote in message news:<41***********************@news.xs4all.nl>...
"Rich Wahl" <ri*******@gmail.com> wrote in message
news:37**************************@posting.google.c om...
I am writing a personal application that uses windowListeners,
ActionListeners and possible ItemListeners (combo boxes).

I have one of the Buttons (ActionListeners) set to have a popup
frame/panel to display a Choice. But I would like the Program to not
continue on until the user makes their selection from the
dropdown/Combo box in the new popup window.

Right now, I have it setup so that the Listeners for the main frame
are looking for the button clicks, and then depending on which is
clicked, it does whatever it has to do. But if the X-Button is
clicked, I wanted it to popup with that window and wait for a
selection to be made (a listener for a combo box).

Is this type of thing possible?

I tried having a flag set, and then just wait until that listener sets
the flag and records the choice. But the program runs too fast, and
the window doesnt pop up fast enough with its contents in order for it
to work.

I hope I made my question understandable. Ill post source if anyone
requests it. But its quite sloppy :) Thank in advance for any
responses on how I can accomplish this type of thing.


You are not looking for nested listeners but nested message-loops instead.
Event driven GUI programs, including Swing programs and Win32 programs,
usually run around a message loop that looks like (extremely simplified
pseudo):

message-loop():
forever do
poll for an event like a mouse-click or key-stroke;
determine which window should receive the event;
pump the event through the registered listeners
end forever

to achieve what you want you would have an event listener (which is called
from inside a message loop already) call message-loop() itself. This is
usually combined with disabling all application windows already visible and
popping up a new one that will be covered by the nested loop.

In short, you want a modal window. Look at JDialog...

Silvio Bierman


All righty, Ill look into that.

Thanks for the response.
Jul 17 '05 #3
> But I would like the Program to not
continue on until the user makes their selection from the
dropdown/Combo box in the new popup window.


Alternatively, you could open a JDialog, passing true to the
constructor, to open a 'modal' dialog. You also need to pass the
'parent' window (the one that shouldnt respond until the dialog is
dismissed).

That will do what (I think) you want, much easier than message driven
loop.

check the API docs.

AJG
Jul 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Hal Vaughan | last post by:
I've said here before that I'm self taught. I have 4 reference books, and they mention listeners and give partial examples, but not one gives me a good, clear example of setting up a listener,...
3
by: Erik Bongers | last post by:
Hi, Nested classes only seem to be able to access static members of the surrounding class : class SurroundingClass { public: class InnerClass { public:
1
by: Fred Mellender | last post by:
When I code: Debug.Assert(false, "this is a message"); it works fine, and out comes the dialog box. When I code Trace.Listeners.Clear(); Debug.Assert(false, "this is a message"); No message...
4
by: Robert W. | last post by:
I'm thinking of building a complex data model with a number of nested classes but need to know something first. To simplify my question, let me present you this sample data model MainClass...
2
by: Michael Powe | last post by:
Hello, Is there a way (in JS) to detect listeners on an element and identify them? The purpose would be to selectively attach additional listeners if certain conditions are met. For example, I...
3
by: Absolon | last post by:
Hi, Can anyone tell the advantages/dis-advantages of adding a listener to the listeners collection? In MSDN it says that listeners not in the collection do not recieve all trace output. What...
0
by: msnews.microsoft.com | last post by:
Hi, I am tring to use Trace Listener in asp.net 1.1 application as mentoned here. But i am getting the following error, Configuration Error Description: An error occurred during the processing...
6
by: Zytan | last post by:
According to http://www.15seconds.com/issue/020910.htm I am doing this in the c'tor of a 'logfile' class: objStream = new System.IO.FileStream(logFilename, System.IO.FileMode.OpenOrCreate);...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.