CODE
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
public class welcome extends JFrame
{
JPanel p;
JButton b1,b2,b3;
public static void main(String [] args)
{
welcome m=new welcome();
}
public welcome()
{
p=new JPanel();
p.setLayout(null);
Font f1=new Font("Calibri",Font.BOLD,45);
Font f2=new Font("Calibri",Font.BOLD,20);
JLabel L1=new JLabel("Welcome to NIIT Student Library");
L1.setFont(f1);
b1=new JButton("Login");
b1.setFont(f2);
b2=new JButton("New User");
b2.setFont(f2);
b3=new JButton("Exit");
b3.setFont(f2);
L1.setBounds(280,170,650,90);
b1.setBounds(320,600,120,50);
b2.setBounds(700,600,170,50);
b3.setBounds(950,740,150,50);
p.add(L1);
p.add(b1);
p.add(b2);
p.add(b3);
this.getContentPane().add(p);
this.setSize(500,500);
this.setVisible(true);
p.setBackground(Color.white);
JLogin login=new JLogin();
JLogin1 login1=new JLogin1();
//JLogin2 login2=new JLogin2();
b1.addActionListener(login);
b2.addActionListener(login1);
//b3.addActionListener(login2);
}
class JLogin implements ActionListener
{
public void actionPerformed(ActionEvent ev)
{
Object ob=ev.getSource();
if(ob==b1)
{
Login L=new Login();
}
}
}
class JLogin1 implements ActionListener
{
public void actionPerformed(ActionEvent sv)
{
Object ob1=sv.getSource();
if(ob1==b2)
{
Signup s=new Signup();
}
}
}
/*class JLogin2 implements ActionListener
{
public void actionPerformed(ActionEvent ae)
{
Object ob2=ae.getSource();
if(ob2==b3);
{
ob2.close();
}
}
}*/
}
Here "Exit" button is coming in output.But i dont know how to use this Button.i ve two more java files i ve posted here.
CODE
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
public class Signup
{
public Signup()
{
JFrame f1=new JFrame("SignUp Form");
JPanel p1=new JPanel();
JLabel l1=new JLabel("Student ID");
JLabel l2=new JLabel("First Name");
JLabel l3=new JLabel("Last Name");
JLabel l4=new JLabel("Password");
JLabel l5=new JLabel("Gender");
String []combopkg={"Male","Female"};
JComboBox gender=new JComboBox(combopkg);
/*JLabel l5=new JLabel("Address");
JLabel l6=new JLabel("City");
JLabel l7=new JLabel("Address of NIIT Center");
JLabel l8=new JLabel("Domicile");
JLabel l9=new JLabel("Country");
JLabel l10=new JLabel("Pincode");*/
JTextField tf1=new JTextField(10);
JTextField tf2=new JTextField(10);
JTextField tf3=new JTextField(10);
/*JTextField tf4=new JTextField(10);
JTextField tf5=new JTextField(10);
JTextField tf6=new JTextField(10);
JTextField tf7=new JTextField(10);
JTextField tf8=new JTextField(10);
JTextField tf9=new JTextField(10);*/
JPasswordField pf=new JPasswordField(10);
JButton b1=new JButton("Create My Account");
l1.setBounds(30,15,150,80);;
tf1.setBounds(120,38,150,29);
l2.setBounds(30,40,100,100);
tf2.setBounds(120,80,150,29);
l3.setBounds(290,64,150,60);
tf3.setBounds(370,80,150,29);
l4.setBounds(30,95,100,80);
pf.setBounds(120,120,150,29);
l5.setBounds(30,125,100,80);
b1.setBounds(400,300,170,50);
p1.add(l1);
p1.add(tf1);
p1.add(l2);
p1.add(tf2);
p1.add(l3);
p1.add(tf3);
p1.add(l4);
p1.add(pf);
p1.add(l5);
p1.add(gender);
p1.add(b1);
pf.setEchoChar('*');
p1.setLayout(null);
f1.getContentPane().add(p1);
f1.setSize(500,500);
f1.setVisible(true);
p1.setBackground(Color.pink);
}
}
Here JcomboBox is not working.when i delete "p1.setLayout(null)" it will work.But i want to use Both.so how can i do...plz help me...this is my project..thanks in advance.
CODE
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
public class Login
{
public Login()
{
JFrame f1=new JFrame();
JPanel p1=new JPanel();
JLabel l1=new JLabel("User Name");
JLabel l2=new JLabel("password");
JTextField tf1=new JTextField(10);
JButton b1=new JButton("Login");
JPasswordField pf=new JPasswordField(10);
l1.setBounds(350,100,650,60);
tf1.setBounds(420,170,650,100);
l2.setBounds(450,170,650,100);
pf.setBounds(420,170,650,100);
b1.setBounds(700,600,170,50);
p1.add(l1);
p1.add(tf1);
p1.add(l2);
p1.add(pf);
p1.add(b1);
pf.setEchoChar('*');
f1.getContentPane().add(p1);
f1.setSize(500,500);
f1.setVisible(true);
p1.setBackground(Color.pink);
}
}
if any thing wrong i do plz forgive me...i am new to this forum..
This post has been edited by suman770: 2 Apr, 2008 - 10:46 PM