/*
no parameters for security reasons
just edit the PASSWORD and URL (see below) and then recompile
next version will read these data from a file (i'm new to java - hehe!)
WebGate.java was written under JDK 1.1.3 by chad d. wessel
cwessel@iname.com
sample *.htm source...
--------------------------------------------------------
<html>
<head>
<title>password_protected</title>
</head>
<body>
<applet code="WebGate.class" width="230" height="148">
</body>
</html>
--------------------------------------------------------
*/
import java.awt.*;
import java.applet.*;
import java.net.*;
public class WebGate extends Applet
{ 
	public void init()
	{
		setLayout(null);
		setSize(230,148);
		setBackground(new Color(16777215));
		submit = new java.awt.Button();
		submit.setActionCommand("button");
		submit.setLabel("Submit");
		submit.setBounds(36,108,60,24);
		submit.setForeground(new Color(16777215));
		submit.setBackground(new Color(-16744448));
		add(submit);
		clear = new java.awt.Button();
		clear.setActionCommand("button");
		clear.setLabel("Clear");
		clear.setBounds(132,108,60,24);
		clear.setForeground(new Color(16777215));
		clear.setBackground(new Color(-16744448));
		add(clear);
		input = new java.awt.TextField();
		input.setEchoChar('*');
		input.setBounds(36,48,156,24);
		input.setBackground(new Color(16777215));
		add(input);
		prompt = new java.awt.Label("Enter Password:",Label.CENTER);
		prompt.setBounds(36,12,156,24);
		prompt.setFont(new Font("Dialog", Font.BOLD, 14));
		prompt.setForeground(new Color(-16744448));
		add(prompt);
		wrong = new java.awt.Label("Invalid Password!",Label.CENTER);
		wrong.setVisible(false);
		wrong.setBounds(36,72,156,23);
		wrong.setFont(new Font("Dialog", Font.BOLD, 12));
		wrong.setForeground(new Color(16777215));
		add(wrong);
		SymMouse aSymMouse = new SymMouse();
		clear.addMouseListener(aSymMouse);
		SymAction lSymAction = new SymAction();
		input.addActionListener(lSymAction);
		submit.addMouseListener(aSymMouse);
	}
		
	public void checkPassword(String temp) {
/********************************************************************************/
//
//	this is where you change the PASSWORD & URL variables, then recompile.
	    String password = "javaboutique";
	    URL gotoURL = null;
	    try {
	        gotoURL = new URL("http://javaboutique.internet.com/password_protect/source.htm");
	    }
	    catch(MalformedURLException e){}
    		    
	    if(password.equals(temp)) {
	        temp = null;
	        if(gotoURL != null) {
	            getAppletContext().showDocument(gotoURL);
	        }
	    }
	    else {
	        wrong.setForeground(Color.red);
	    }
	}
//
//	that's it... you're finished!  =)
//
/********************************************************************************/
  
	java.awt.Button submit;
	java.awt.Button clear;
	java.awt.TextField input;
	java.awt.Label prompt;
	java.awt.Label wrong;
	class SymMouse extends java.awt.event.MouseAdapter
	{
		public void mouseClicked(java.awt.event.MouseEvent event)
		{
			Object object = event.getSource();
			if (object == clear)
				clear_MouseClick(event);
			else if (object == submit)
				submit_MouseClick(event);
		}
	}
	void clear_MouseClick(java.awt.event.MouseEvent event)
	{
		input.setText("");
		wrong.setForeground(Color.white);
	}
	class SymAction implements java.awt.event.ActionListener
	{
		public void actionPerformed(java.awt.event.ActionEvent event)
		{
			Object object = event.getSource();
			if (object == input)
				input_EnterHit(event);
		}
	}
	void input_EnterHit(java.awt.event.ActionEvent event)
	{
		String temp = null;
		temp = input.getText();
		checkPassword(temp);
	}
	void submit_MouseClick(java.awt.event.MouseEvent event)
	{
		String temp = null;
		temp = input.getText();
		checkPassword(temp);
	}
}

 
