Solved

Help required in java applets

Posted on 2001-06-26
4
178 Views
Last Modified: 2013-11-23
hi all
    can we open two windows or frames in one applet?
What i wanna do is that to open two windows or frames in an applet and what i write in one edit box in one window is also written in the second edit box in the other window simultaneously.
     Looking for some code hints as early as possible
0
Comment
Question by:umargul
[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
4 Comments
 
LVL 2

Expert Comment

by:iDeb
ID: 6229209
The way to do this would be maintain a reference of the windows with each other. Now the confusing portion of your question is whether you are talking about html frames or java frames....please elaborate on your problem
0
 
LVL 1

Expert Comment

by:viswa081400
ID: 6229452
You can communicate with applets with in the same html page, using the AppletContext. AppletContext gives you references of all Applets in its scope.

getAppletContext() method gives you the applet context of the current applet.

And you can enumerate the Applets in the context and fet reference of the required applet.

good luck  
-viswa
0
 

Author Comment

by:umargul
ID: 6231981
Firstly I am talking about the java frames and secondly there is only one applet on which I have to open two frames.
0
 
LVL 15

Accepted Solution

by:
mohan_sekar earned 50 total points
ID: 6232121
Hi,

  try this code (though the GUI is not perfect). It has got the answer for your question.

import java.awt.*;
import java.awt.event.*;
import java.applet.*;

public class try1 extends Applet implements TextListener
{
          TextField t1=new TextField(10);
          TextField t2=new TextField(10);
     public void init()
     {
          Frame f=new Frame("Frame1");
          f.setLayout(new FlowLayout());
          Frame f1=new Frame("Frame2");
          f1.setLayout(new FlowLayout());
          f.add(t1);
          t1.addTextListener(this);
          f1.add(t2);          
          t2.addTextListener(this);
          f.show();
          f1.show();
     }
     public void start()
     {
     }
     public void paint(Graphics g)
     {
     }
     public void textValueChanged(TextEvent te)
     {
          t2.setText(t1.getText());
     }
//<applet code="try1" width="400" height="400"></applet>
}

bye
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

Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
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 …
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…

756 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