------------------------------ master.html ------------------------------ Test TestFrame ------------------------------ testf.html ------------------------------

testframe.....

------------------------------ HelloWorld.java ------------------------------ import javax.swing.*; import java.awt.*; import java.util.*; public class HelloWorld extends JApplet { String myString = new String("Hello, world!"); int id = -1; String frameName = ""; boolean red = false; static Hashtable applets = new Hashtable(); static int counter = -1; JTextArea area = new JTextArea(myString); public void init() { id = ++counter; System.out.println("Init Applet with id = "+id); applets.put(id+"",this); area.setRows(20); area.setColumns(80); this.getContentPane().add(area); } public void setSizeFromFrame(int width,int height) { System.out.println("applet "+id+" "+"width "+width+" height "+height); } public void paint(Graphics g) { } public void switchColor() { if(red) area.setBackground(Color.white); else area.setBackground(Color.red); red=!red; } public void setFrameName(String name) { frameName = name; System.out.println("Framename : "+name+" id :"+id); } public String getFrameName() { return frameName; } public String getId() { return id+""; } public String getText() { return myString; } public void stop () { applets.remove(id+""); } public void setText(String aString) { myString = aString; applets.put(id+"",this); int i = 1; String printout=""; String key; String output; HelloWorld tmp; for(Enumeration e = applets.keys(); e.hasMoreElements();) { key = (String) e.nextElement(); tmp=(HelloWorld) applets.get(key); printout = printout+key+" "+tmp.getFrameName()+" "+tmp.getText()+"\n"; if(!tmp.getFrameName().equals(frameName)) tmp.switchColor(); } System.out.println(printout); area.setText(printout); this.getContentPane().repaint(); } }