Solved

Help required in java applets

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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
firstswap challenge 20 77
JUnit 4 @Before and @BeforeClass differences 3 59
maven module vs maven project 3 21
Which non-HTML GUI front end to use with Java? 3 21
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
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 about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:

808 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