[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

passing info from dialog

Posted on 1998-06-16
2
Medium Priority
?
182 Views
Last Modified: 2010-03-30
Im writing a graphing program that has default headings when the user starts the program.  I wanted to give the
user the ability to change the heading text if they so desired.
So I created a series of menu selections to allow the user to change the text of the various headings.
When the user selects one of these menu selections (say the main heading) a dialog box appears asking for
the text of the new heading.
There is also an OK and a CANCEL button on the dialog box...
My problem is how do I send the info that is entered in the textfield back to the original frame so I can call the appropriate method to erase the main heading and draw the new one
And do I need to use the AWTEventMulticaster to assign all the events to the dialog itself (instead of the components in it) and go from there?

I can produce some code to look at if need be however it is fairly long and its kind of a generic question.

Also does anyone know where I can find some freeware classes for graphing or better yet just some algorithms so i dont have to "reinvent the wheel"?  (I know this is really a separate question but i thought if someone knew of a site off the top of their head... I suppose I would learn a lot more if i did it myself.. although it probably wouldnt be the most efficient way)

Thanks in advance
0
Comment
Question by:mbunkows
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 4

Accepted Solution

by:
evijay earned 400 total points
ID: 1223297
This is a problem of implementing preference Changer. It can be done by seperation of concerns and responsibilities.

I think you have a main graphing class which has a paint method and which stores the headings and other state info that need to render the graph.
Lets call this as

Grapher



Your grapher class should implement PreferenceModal interface which has methods to get/set the current graphing preferences.

Now, you have another class called PreferenceCustomizer Which displays a dialog containing user preferences and takes the details. PreferenceCustomizer takes an object that implements PreferenceModal as its constructor. It displays the dialog , populates current preferences using get methods of PreferenceModal object and when user changes the preferences, it invokes the methods on PreferenceModal object.Now,  going for code


public interface PreferenceModal {
   public String getHeading ();
   public void setHeading(String s);
  // add other preferences here

}

public class Grapher implements PreferenceModal {
   public String getHeading () {
            // implementation - may get the variable from a member variable
  }
   public void setHeading(String s){
     //implementation - may call repaint
   }

}

public class PreferenceCustomizer extends Dialog {
    public PreferenceCustomizer(PreferenceModal pm)
   {
        // create controls and populate it using get methods of    pm. also add handlers
   }

   public void actionPerformed (...)
  {
       // validate and if ok, call setMethods of pm
  }

}
   


// the main code in main method/init method

Grapher g = new Grapher();
PreferenceChanger pc = new PreferenceChanger(g);

// add these where ever you want





0
 

Author Comment

by:mbunkows
ID: 1223298
oh yeah that sounds logical

darn pretty too

Thanks alot

0

Featured Post

Enroll in October's Free Course of the Month

Do you work with and analyze data? Enroll in October's Course of the Month for 7+ hours of SQL training, allowing you to quickly and efficiently store or retrieve data. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
This video teaches viewers about errors in exception handling.
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
Suggested Courses

656 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