Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Applet Problem

Status
Not open for further replies.

egobbitz

Programmer
Oct 18, 2002
47
US
Hi guys,
I am trying to write an applet to put on a web document at work. My users all have IE using the default Microsoft JVM. I wrote a basic applet to display a new window based on a choice from a list box, and it is not displaying. Can you tell me what I might have to do to get it to display without having to have the java plug in installed on the target PC's?

Here is the code, very simple stuff.

Code:
import java.awt.*;
import java.applet.*;
import java.awt.event.*;
import java.net.*;

/* 
<applet code = &quot;RejectApplet.class&quot;
width = 300 height = 300>
</applet>

*/


public class RejectApplet extends Applet implements ActionListener
{
	
	Panel p1;
	Panel p2;
	Label label;
	URL url;
	
	List l1;

public void init()
{
	setLayout(new GridLayout(2,1,5,5));
	l1 = new List();
	l1.addActionListener(this);
	p1 = new Panel();
	p2 = new Panel();
	label = new Label(&quot;Choose an option&quot;);

	

	l1.add(&quot;Add a printer&quot;);

	p1.add(label);
	p2.add(l1);

	add(p1);
	add(p2);

}

public void actionPerformed(ActionEvent ie) 
{
	String command = ie.getActionCommand();
	System.out.println(command);
	if(command.equals(&quot;Add a printer&quot;))
	{
		AppletContext ac = getAppletContext();
		try{
			url = new URL(getDocumentBase(),&quot;Addprnt.html&quot;);
		}catch( MalformedURLException m)
		{
			System.out.println(&quot;Not a valid url&quot;);
		}	
		ac.showDocument(url,&quot;blank&quot;);
	}
}


}

Thanks.

Nick
 
Nevermind, I figured it out. I had to use a compiler option of -target 1.1 to get it to that standard.

thanks anyway.

Nick
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top