Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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

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…
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
Suggested Courses

670 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