I have designed a GUI which is a simple login Screen, the code is as below,
================================================================================\
===========
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class logInApplet extends JApplet
{
public void init()
{
getContentPane().add(new LogIn(),BorderLayout.CENTER);
}
}
class LogIn extends JPanel
{
JSeparator sep = new JSeparator();
JLabel title = new JLabel("LOGIN FORM");
JLabel userid = new JLabel("User ID",JLabel.LEFT);
JLabel pwd = new JLabel("Password", JLabel.LEFT);
JTextField uid = new JTextField(25);
JTextField passwd = new JTextField(25);
JButton signin = new JButton("SignIn");
JButton cancel = new JButton("Cancel");
public LogIn()
{
GridBagLayout gbl = new GridBagLayout();
GridBagConstraints gbc = new GridBagConstraints();
setLayout(gbl);
title.setFont(new Font("Times-Roman",Font.BOLD,40));
gbc.anchor = GridBagConstraints.NORTHWEST;
gbc.gridwidth = GridBagConstraints.REMAINDER;
add(title,gbc);
gbc.anchor = GridBagConstraints.NORTH;
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.insets = new Insets(0,0,10,0);
add(sep,gbc);
userid.setFont(new Font("Times-Roman", Font.BOLD,22));
gbc.anchor = GridBagConstraints.WEST;
gbc.gridwidth = 1;
gbc.insets = new Insets(0,0,0,0);
add(userid,gbc);
add(Box.createHorizontalStrut(10));
gbc.gridwidth = GridBagConstraints.REMAINDER;
add(uid,gbc);
pwd.setFont(new Font("Times-Roman", Font.BOLD,22));
gbc.gridwidth = 1;
add(pwd,gbc);
add(Box.createHorizontalStrut(10));
gbc.gridwidth = GridBagConstraints.REMAINDER;
add(uid,gbc);
ButtonPanel buttonPanel = new ButtonPanel();
buttonPanel.add(signin);
buttonPanel.add(cancel);
gbc.anchor = GridBagConstraints.SOUTH;
gbc.insets = new Insets(15,0,0,0);
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.gridwidth = 7;
add(buttonPanel,gbc);
}
class ButtonPanel extends JPanel
{
JPanel buttonPanel = new JPanel();
JSeparator seperator = new JSeparator();
public ButtonPanel()
{
buttonPanel.setLayout(new FlowLayout(FlowLayout.CENTER));
setLayout(new BorderLayout(0,5));
add(seperator,"North");
add(buttonPanel,"Center");
}
public void add(JButton button)
{
buttonPanel.add(button);
}
}
}
there is a runtime error(IO Exception while reading, using appletviewer) in
this, should i include the <applet> tag to remove the same or there is some
other problem.
I want to make this to run as an application, what changes should I make to do
this.
Also, how do i check on click of SIGNIN that the values entered are there in the
table(how do i get JDBC going here)