Solved

How to get the Value ?

Posted on 2002-03-07
4
151 Views
Last Modified: 2010-03-31
Hi

I have a JPopupMenu.When I right click on the Menu
I am loading a wizard screen

basically I am loading a new JFrame

which has a Jbutton "finish" and many JTextFields

Now when the user presses "finish"
I have to get the values entered in the JTextField
in the main class which loaded the Wizard

I dont have the reference of the textfields in the main class.

How do I do this?

please help



0
Comment
Question by:sanjay_thakur
  • 3
4 Comments
 
LVL 4

Author Comment

by:sanjay_thakur
Comment Utility
The problem is when the user presses the finish button
Then I have to read the values of all the Textfields
in some data structure (say a hashmap)and send it to the
mainframe who invoked the wizard

But I dont have any reference of the finish button in the main frame
So when the user presses the finish button in the wizard screen how do I
send this event to the main frame

 public void gui_VolumeMenu()
    {
       //here I am loading the new frame
       WizardFrame  frame = new VolumeWizard1();
       
        /**I need to do this when the user presses the    
        finish button in the new Frame ?????**/
        Iterator i = data.iterator();
        while(i.hasNext())
        {
          System.out.println("next" + i.next());
        }
       

}


0
 
LVL 9

Accepted Solution

by:
Ovi earned 50 total points
Comment Utility
The main class can register itself as listener to the wizard ? If yes you could generate a event when the finish button was pressed, and put in that event your hashmap with results.

If not, you could implement a class (maybe static) for notification let's say Dispatcher, to which your main class listen for notification. When you push the finish button, you will notify the Dispatcher that you have some results and pass'it to it. The Dispatcher then notify the main class (or all listeners for that kind of event) and send the data. You can extend further this pattern in forcing each class which want's notification of some kind to implement a general interface, register that interface to the Dispatcher, and put the Dispatcher to directly set the data using the interface methods.
0
 
LVL 4

Author Comment

by:sanjay_thakur
Comment Utility
Hi could you please post some source code/links
for the second option

It would be really helpful

Thanka a ton
0
 
LVL 4

Author Comment

by:sanjay_thakur
Comment Utility
I follwed the guidelines and implemented it

Thanks a ton

0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
This video teaches viewers about errors in exception handling.

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now