Solved

How to get the Value ?

Posted on 2002-03-07
4
165 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
ID: 6847935
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
ID: 6849893
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
ID: 6850990
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
ID: 6942498
I follwed the guidelines and implemented it

Thanks a ton

0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
The viewer will learn how to implement Singleton Design Pattern in Java.

911 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

26 Experts available now in Live!

Get 1:1 Help Now