Solved

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

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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
Suggested Courses

631 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