Solved

Help required in java applets

Posted on 2001-06-26
4
174 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
4 Comments
 
LVL 2

Expert Comment

by:iDeb
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

For customizing the look of your lightweight component and making it look opaque like it was made of plastic.  This tip assumes your component to be of rectangular shape and completely opaque.   (CODE)
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 learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:

771 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

11 Experts available now in Live!

Get 1:1 Help Now