473,774 Members | 2,138 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 (ActionListener s) 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 2657

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

I have one of the Buttons (ActionListener s) 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.n l>...
"Rich Wahl" <ri*******@gmai l.com> wrote in message
news:37******** *************** ***@posting.goo gle.com...
I am writing a personal application that uses windowListeners ,
ActionListeners and possible ItemListeners (combo boxes).

I have one of the Buttons (ActionListener s) 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
3013
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, using it, and disposing it. Can anyone either point me to some good examples online, or show me one? It would save me a day or two of try different ways to do it. Thanks for any help. Hal
3
2407
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
1856
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 is output. In the debugger I see that clearing the Trace Listeners clears the Debug
4
1168
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 Questions (collection) Question (class) Text (property) Answers (collection) Answer (class)
2
1727
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 want to attach listenerA to links that go to PDFs and listenerB to links that go off site. But, I don't want both A and B attached to offsite links that point to PDFs. I would like to be able to choose which to attach, so that
3
1548
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 will be missing? -- Rgds,
0
1652
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 of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately. Parser Error Message: Exception in configuration section handler.
6
3958
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); objTraceListener = new TextWriterTraceListener(objStream); Trace.Listeners.Add(objTraceListener); So, now all Debug.Write and Trace.Write get logged to the file. In the d'tor I am doing:
0
9454
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10267
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10106
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10040
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8939
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7463
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6717
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5484
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3611
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.