Solved

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

Posted on 1998-11-02
1
153 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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
changeXy challenge 13 58
groupSum6 challenge 6 48
solarwind tftp server 2 32
backtracking recursion  code 19 41
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
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 …
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.

744 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

12 Experts available now in Live!

Get 1:1 Help Now