?
Solved

Help required in java applets

Posted on 2001-06-26
4
Medium Priority
?
182 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 150 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

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

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

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…
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…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.
Suggested Courses
Course of the Month12 days, 23 hours left to enroll

777 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