Solved

get and set data from and to text boxes in a frame

Posted on 1998-11-02
1
173 Views
Last Modified: 2010-03-30
i have some text boxes in the main frame and i want to get from it and insert to it data.
as the main frame file is already big enough, i wonder if there is a good way to achive my two goals and not doing this in the main frame file.
1. i believe that i have to pass the frmae name as a parameter. can you give me an example?
2. suppose i do it in a different file, is it good programming to write a class that all its purpose is to handle with these two things?
thank you.
0
Comment
Question by:rzvika3
1 Comment
 
LVL 7

Accepted Solution

by:
conick earned 20 total points
ID: 1226875

Are you trying to pass data between two frames (or a dialog and a frame) OR
are you passing data between text boxes?

I'll give you a psuedocode example of what is normally (i think) done when passing data between a frame and a dialog... Let me know if you need a real world example:

First Define an Interface:

    public interface DataTransfer{
       public String getData ();
       public void setData(String s);
    }  

    public class TheFrame extends Frame implements DataTransfer {
       
    String dataString;
   

    public String getData () {
                 return dataString;
      }
       public void setData(String s){
                 dataString = s;          
       }
    }

    public class TheDialog extends Dialog {
        public TheDialog(DataTransfer dt)
       {
       ...
       TextField tf= new TextField();
       tf.setText(dt.getData());
      ...
      }

       public void actionPerformed (...)   {      // when you want data transfered
     
            pf.setData(tf.getText());  
      }


So question #1:  <see above>
question #2:  Thats basically what interfaces are designed for

The implementation is dont in the main frame but the methods included in the interface
so the Dialog or other class can use them when an instance is passed.

Thats at least how I understand it...
Ive used this technique before and it works well            
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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)
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
The viewer will learn how to implement Singleton Design Pattern in Java.

792 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