Solved

How to get the Value ?

Posted on 2002-03-07
4
179 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

For customizing the look of your lightweight component and making it look opaque like it was made of plastic.  This tip assumes your component to be of rectangular shape and completely opaque.   (CODE)
After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

861 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