Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 1998-11-02
1
Medium Priority
?
196 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 60 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
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…
The viewer will learn how to implement Singleton Design Pattern in Java.
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.
Suggested Courses

927 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