Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / First Aid / April 2005

Tip: Looking for answers? Try searching our database.

Java Applet - shared one VM problem

Thread view: 
00_DotNetWarrior - 29 Apr 2005 19:49 GMT
I have a very simple Java Applet (see below), when I launched 2 browsers
(say 2 Netscapes or firefox, with latest Sun Java VM 1.5.0), pointing to the
same Java Applet. They shared the SAME Java VM!!!! When clicking on the
start button, the text is printing to the wrong browser!!! Help...  because
my application is allowed to have multiple instances access from the same
desktop. Please help........

import java.awt.*;
import java.awt.event.*;
import java.applet.Applet;
import javax.swing.*;
import java.sql.*;
import java.util.*;
import java.net.*;
import java.lang.*;
import java.io.*;

public class Share extends Applet implements  Runnable, ActionListener {

private static TextArea my_message_area;
private Button my_button;
public Share() {
}

public void actionPerformed(ActionEvent e) {
 String arg = e.getActionCommand();

  if ("start".equals(arg))  {
    print_me();
  }

}

public String getAppletInfo() {
 return "test";
}

private void print_me() {
 my_message_area.append("\ntesting");
}

public void init() {
 my_button = new Button("start");
 my_message_area= new TextArea("", 9, 40);
 my_message_area.setEditable(false);
 setLayout(new BorderLayout());
    my_button.addActionListener(this);
 add("North", my_message_area);
 add("South", my_button);

}

public void start() {
}
public void stop() {
}
public void run() {
}
}
00_DotNetWarrior - 29 Apr 2005 20:08 GMT
I figured out myself...  stupid mistake I defined it as "static" !!!
problem solved.

> I have a very simple Java Applet (see below), when I launched 2 browsers
> (say 2 Netscapes or firefox, with latest Sun Java VM 1.5.0), pointing to the
[quoted text clipped - 55 lines]
>  }
> }


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.