// file: Varmint.java
//

// import necessary java libraries
//
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.util.*;

class VarmintLogin extends JPanel implements ActionListener {
    
    JTextField login;
    JPasswordField passwd;
    
    boolean is_applet_d;

    VarmintLogin(boolean is_applet) {

	is_applet_d = is_applet;

	JPanel main = new JPanel();
	
	main.setLayout(new BoxLayout(main, BoxLayout.Y_AXIS));
	
	JLabel l = new JLabel("Welcome to WebVarmint");
	l.setAlignmentX(Component.CENTER_ALIGNMENT);
	main.add(l);
	
	main.add(Box.createRigidArea(new Dimension(0, 10)));
	
	JPanel line = new JPanel();

	line.setLayout(new BoxLayout(line, BoxLayout.X_AXIS));

	line.add(Box.createRigidArea(new Dimension(10, 0)));
	
	Dimension lab_d = new Dimension(80, 20);
	Dimension text_d = new Dimension(140, 20);
	JLabel lab = new JLabel("Login:");
	lab.setPreferredSize(lab_d);
	lab.setMinimumSize(lab_d);
	login = new JTextField();

	login.setPreferredSize(text_d);
	login.setMinimumSize(text_d);
	line.add(lab);
	line.add(login);
	main.add(line);

	main.add(Box.createRigidArea(new Dimension(0, 10)));

	line = new JPanel();
	line.setLayout(new BoxLayout(line, BoxLayout.X_AXIS));

	line.add(Box.createRigidArea(new Dimension(10, 0)));

	lab = new JLabel("Password:");
	lab.setPreferredSize(lab_d);
	lab.setMinimumSize(lab_d);
	passwd = new JPasswordField();

	passwd.setPreferredSize(text_d);
	passwd.setMinimumSize(text_d);
	line.add(lab);
	line.add(passwd);
	main.add(line);

	main.add(Box.createRigidArea(new Dimension(0, 10)));
	
	JButton b = new JButton("Login");
	b.addActionListener(this);
	b.setActionCommand("login");
	b.setAlignmentX(Component.CENTER_ALIGNMENT);
	main.add(b);
	
	main.add(Box.createRigidArea(new Dimension(0, 10)));

	add(main);
    }

    public void actionPerformed(ActionEvent e) {
	
	String p = new String(passwd.getPassword());
	String user = login.getText();
	
	VarmintDB._user = "webvarmint";
	VarmintDB._pWord = p;

	JFrame f = new JFrame();
	VarmintPanel varmintPanel = new VarmintPanel(user, is_applet_d, f);
	    
	f.getContentPane().add(varmintPanel);
	f.pack();
	f.setVisible(true);
    }

    public static void main(String[] args) {
	
	JFrame f = new JFrame();
	f.setSize(300,200);
	
	VarmintLogin l = new VarmintLogin(false);
	f.getContentPane().add(l);
	
	f.pack();
	f.setVisible(true);
    }
}

public class VarmintApp extends JApplet {

    // declare global variables
    //
    private static JFrame  mainFrame = null;
    
    private static String user = null;

    JButton b1;
    public static JLabel err_label;
    
    public VarmintApp() {
        getRootPane().putClientProperty("defeatSystemEventQueueCheck",
					Boolean.TRUE);
    }

    public void init() {

	VarmintLogin l = new VarmintLogin(true);
	getContentPane().add(l, BorderLayout.CENTER);
    }
} 

//
// end of file
