Solved

Help required in java applets

Posted on 2001-06-26
4
181 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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
In this post we will learn different types of Android Layout and some basics of an Android App.
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…

688 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