package JAVAPROJECT;
import javax.imageio.*;
import javax.swing.*;
import java.io.*;
import java.awt.image.*;
import java.awt.*;
import java.awt.event.*;
public class FORM0 extends JFrame implements ActionListener
{
JLabel j1;
JButton b1;
Container con= getContentPane();
Font f;
JTextField tf1;
JPasswordField tf2;
public FORM1 f1;
static FORM0 cls1=null;
public FORM0(String s)
{
super(s);
con.setLayout(null);
j1=new JLabel(new ImageIcon(this.getImage()));
j1.setLocation(0,0);
j1.setSize(1300, 100);
con.add(j1);
j1=new JLabel("USER NAME ");
f=new Font("Helvetica",Font.BOLD,12);
j1.setFont(f);
j1.setForeground(Color.BLACK);
j1.setLocation(610,300);
j1.setSize(200,80);
con.add(j1);
j1=new JLabel("PASSWORD ");
f=new Font("Helvetica",Font.BOLD,12);
j1.setFont(f);
j1.setForeground(Color.BLACK);
j1.setLocation(610,340);
j1.setSize(200,80);
con.add(j1);
//USERNAME TEXTFIELD
tf1=new JTextField();
tf1.setLocation(600,350);
tf1.setSize(100,20);
con.add(tf1);
//PASSWORD TEXTFIELD
tf2=new JPasswordField();
tf2.setLocation(600,390);
tf2.setSize(100,20);
con.add(tf2);
//SUBMIT BUTTON
b1=new JButton("SUBMIT");
b1.setLocation(605,430);
b1.setSize(90,20);
con.add(b1);
b1.addActionListener(this);
//IMAGE ICON
j1=new JLabel(new ImageIcon(this.getImage()));
j1.setLocation(500,350);
j1.setSize(100, 80);
con.add(j1);
setSize(1300,770);
setVisible(true);
}
public void actionPerformed(ActionEvent e)
{
if(e.getSource()==b1)
{
if(tf1.getText().equals("ADMIN") && tf2.getText().equals("ADMIN"))
{
JOptionPane.showMessageDialog(cls1,"Login Successful");
f1=new FORM1("ADMIN");
cls1.setVisible(false);
// JOptionPane.showMessageDialog(cls1,"Login Successful");
}
else if(tf1.getText().equals("") && tf2.getText().equals(""))
{
JOptionPane.showMessageDialog(cls1,"Please Enter Username & Password");
}
else
{
JOptionPane.showMessageDialog(cls1,"Login Failed");
tf1.setText("");
tf2.setText("");
}
}
}
private Image getImage(){
try{
BufferedImage buffImg = ImageIO.read(new File("C:\\Users\\Sandeep\\Documents\\NetBeansProje cts\\CARROT.jpg"));
Image image = buffImg.getScaledInstance(1300,100,Image.SCALE_SMO OTH);
return image;
}catch(IOException ioe){
ioe.printStackTrace();
return null;
}
}
/*public static void main(String ar[])
{
cls1=new FORM0("ADMIN ");
cls1.setResizable(false);
cls1.setSize(1300,770);
cls1.setVisible(true);
}*/
}
Here is my code. I want to draw a three rectangles to separate (image), (Username label,Password Label and Text fields) and (SUBMIT Button). It should look Like a boundry.
Last edited by SANDY_INDIA; 07-06-2008 at 09:02 AM.
|