import javax.swing.*;
import java.awt.*;
import java.io.*;
import java.awt.event.*;
public class studreg extends JFrame{
JFrame frame=new JFrame();
int i,a,j;
JLabel l1,l2,l3,l4,l5,l6,l7,l8,l9,l10,l11,l12,l13,l14,l15,l16,l17;
JTextField t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12;
JCheckBox c3,c4;
JRadioButton r1,r2;
JButton Apply,Save,Exit;
JPanel contentPane;
JComboBox z;
JComboBox k;
JComboBox d,m,y;
JList l;
GridBagLayout gl=new GridBagLayout();
GridBagConstraints gbc=new GridBagConstraints();
public studreg()
{
super("STUDENT REGISTRATION FORM");
l1=new JLabel("FULL NAME");
l2=new JLabel("ADDRESS");
l3=new JLabel("TELEPHONE");
l4=new JLabel("EnterGender");
l5=new JLabel("COURSE");
l6=new JLabel("DATE OF BIRTH");
l7=new JLabel("COLLEGE ENTRY YR");
l8=new JLabel("REG NUMBER");
l9=new JLabel("HOME DISTRICT");
l10=new JLabel("VILLAGE");
l11=new JLabel("TA");
l12=new JLabel("NEXTOFKINDETAILS");
l13=new JLabel("FULL NAME");
l14=new JLabel("POSTAL ADDRESS");
l15=new JLabel("TEL/CELL");
l16=new JLabel("EMAIL");
l17=new JLabel("POLY REGISTRATION FORM");
l1.setFont(new Font("Elephant",Font.BOLD,16));
l2.setFont(new Font("Elephant",Font.BOLD,16));
l3.setFont(new Font("Elephant",Font.BOLD,16));
l4.setFont(new Font("Elephant",Font.BOLD,16));
l5.setFont(new Font("Elephant",Font.BOLD,16));
l6.setFont(new Font("Elephant",Font.BOLD,16));
l7.setFont(new Font("Elephant",Font.BOLD,16));
l8.setFont(new Font("Elephant",Font.BOLD,16));
l9.setFont(new Font("Elephant",Font.BOLD,16));
l10.setFont(new Font("Elephant",Font.BOLD,16));
l11.setFont(new Font("Elephant",Font.BOLD,16));
l12.setFont(new Font("Elephant",Font.BOLD,16));
l13.setFont(new Font("Elephant",Font.BOLD,16));
l14.setFont(new Font("Elephant",Font.BOLD,16));
l15.setFont(new Font("Elephant",Font.BOLD,16));
l16.setFont(new Font("Elephant",Font.BOLD,16));
l17.setFont(new Font("Elephant",Font.BOLD,16));
k=new JComboBox();
k.addItem("BAC 4");
k.addItem("BBA 4");
k.addItem("BIT 4");
k.addItem("MSE 4");
k.addItem("TED 4");
z=new JComboBox();
for (j=2003;j<=2009;j++)
{
z.addItem(""+j);
}
r1=new JRadioButton("Male");
r2=new JRadioButton("Female");
Apply=new JButton("Apply");
Save=new JButton("Save");
Exit=new JButton("Exit");
t1=new JTextField();
t2=new JTextField(10);
t3=new JTextField(10);
t4=new JTextField(10);
t5=new JTextField(10);
t6=new JTextField(10);
t7=new JTextField(10);
t8=new JTextField(10);
t9=new JTextField(10);
t10=new JTextField(10);
t11=new JTextField();
t12=new JTextField();
t1.setFont(new Font("Venderna",Font.BOLD,15));
t2.setFont(new Font("Venderna",Font.BOLD,15));
t3.setFont(new Font("Venderna",Font.BOLD,15));
t4.setFont(new Font("Venderna",Font.BOLD,15));
t5.setFont(new Font("Venderna",Font.BOLD,15));
t6.setFont(new Font("Venderna",Font.BOLD,15));
t7.setFont(new Font("Venderna",Font.BOLD,15));
t8.setFont(new Font("Venderna",Font.BOLD,15));
t9.setFont(new Font("Venderna",Font.BOLD,15));
t10.setFont(new Font("Venderna",Font.BOLD,15));
t11.setFont(new Font("Venderna",Font.BOLD,15));
t12.setFont(new Font("Venderna",Font.BOLD,15));
d=new JComboBox();
m=new JComboBox();
y=new JComboBox();
for(i=1;i<=31;i++)
d.addItem(" "+i);
m.addItem("Jan");
m.addItem("Feb");
m.addItem("Mar");
m.addItem("Apr");
m.addItem("May");
m.addItem("Jun");
m.addItem("Jul");
m.addItem("Aug");
m.addItem("Sept");
m.addItem("Oct");
m.addItem("Nov");
m.addItem("Dec");
for(a=1975;a<=1992;a++)
{
y.addItem(""+a);
}
contentPane=(JPanel)this.getContentPane();
File file = new File("PERSONAL DETAILS.DOC");
t1.setText(" ");
t11.setText(" ");
t2.setText(" ");
l4.setText("GENDER");
l5.setText("COURSE");
l6.setText("DATE OF BIRTH");
t3.setText(" ");
t5.setText(" ");
t6.setText(" ");
t7.setText(" ");
l12.setText("NEXT OF KIN DETAILS");
l12.setFont(new Font("Elephant",Font.BOLD,16));
t8.setText(" ");
t12.setText(" ");
t9.setText(" ");
t10.setText(" ");
r1.setText("Male");
r1.setSelected(true);
r2.setText("Female");
r2.setSelected(true);
Apply.setText("Apply");
Apply.addActionListener(
new ActionListener(){
public void actionPerformed(ActionEvent e){
JTextArea textarea=new JTextArea();
JScrollPane scroll=new JScrollPane( textarea,
JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
JFrame frame= new JFrame();
if (e.getSource()==Apply){
String name= t1.getText();
textarea.append("NAME: "+name+"\n\n");
if (r2.isSelected())
textarea.append("SEX: Female");
if (r1.isSelected())
textarea.append("SEX: Male\n\n");
String name1= t11.getText();
textarea.append("HOME ADDRESS: "+name1+"\n\n");
String name3 = t2.getText();
textarea.append("TELEPHONE #: "+ name3+"\n\n");
String name4=t5.getText();
textarea.append("HOME DISTRICT: "+name4+"\t");
String name5= t6.getText();
textarea.append("VILLAGE: "+name5+"\t");
String name6=t7.getText();
textarea.append("T/A: "+name6+"\n\n");
String name12 = (String)d.getSelectedItem();
textarea.append("DATE OF BIRTH: "+name12+" ");
String name13 = (String)m.getSelectedItem();
textarea.append(name13+" ");
String name14 = (String)y.getSelectedItem();
textarea.append(name14+"\n\n");
String name2=t3.getText();
textarea.append("REGISTRATION NUMBER: "+name2+"\n\n");
String enteredText = (String)z.getSelectedItem();
textarea.append("COLLEGE ENTRY YEAR: "+enteredText+"\n\n");
String name11= (String)k.getSelectedItem();
textarea.append("COURSE: "+name11+"\n\n");
String name15=l12.getText();
textarea.append("\t\tNEXT OF KIN DETAILS\t\t\n\n");
String name7= t8.getText();
textarea.append("FULL NAME: "+name7+"\n\n");
String name8= t9.getText();
textarea.append("TEL/CELL: "+name8+"\n\n");
String name9= t12.getText();
textarea.append("POSTAL ADDRESS: "+name9+"\n\n");
String name10= t10.getText();
textarea.append("EMAIL: "+name10+" ");
textarea.setFont(new Font("Elephant",Font.BOLD,16));
textarea.setEditable(false);
}
frame.add(scroll);
frame.setTitle("APPLICANT'S PERSONAL DETAILS");
frame.setSize(500,500);
frame.setLocation(350,50);
frame.setVisible(true);
}
});
Exit.setText(" Exit");
Exit.addActionListener(
new ActionListener() {
public void actionPerformed(ActionEvent e)
{
System.exit(0);
}
});
gbc.fill=GridBagConstraints.BOTH;
gbc.weightx=100.0;
gbc.weighty=100.0;
put(0,2,1,1,l17);
put(1,0,1,1,l1);
put(1,1,1,1,t1);
put(2,2,1,1,l8);
put(2,3,1,1,t3);
put(2,0,1,1,l2);
put(2,1,1,1,t11);
put(3,0,1,1,l3);
put(3,1,1,1,t2);
put(3,2,1,1,l7);
put(3,3,1,1,z);
put(4,0,1,1,l4);
put(4,1,1,1,r1);
put(4,2,1,1,r2);
put(5,0,1,1,l9);
put(5,1,1,1,t5);
put(5,2,1,1,l10);
put(5,3,1,1,t6);
put(5,4,1,1,l11);
put(5,5,1,1,t7);
put(6,0,1,1,l5);
put(6,1,1,1,k);
put(7,0,1,1,l6);
put(7,1,1,1,d);
put(7,2,1,1,m);
put(7,3,1,1,y);
put(10,2,1,1,l12);
put(11,0,1,1,l13);
put(11,1,1,1,t8);
put(12,0,1,1,l14);
put(12,1,1,1,t12);
put(11,2,1,1,l15);
put(11,3,1,1,t9);
put(12,2,1,1,l16);
put(12,3,1,1,t10);
put(13,1,1,1,Apply);
put(13,2,1,1,Save);
put(13,3,1,1,Exit);
Save.addMouseListener(new Save());
setSize(900,700);
setLocationRelativeTo(null);
setVisible(true);
setResizable(true);
}
public class Save extends MouseAdapter{
public void mouseClicked(MouseEvent e)
{
JFrame aFrame = new JFrame();
JFileChooser fChooser = new JFileChooser();
int result = fChooser.showSaveDialog(aFrame);
if(result==JFileChooser.APPROVE_OPTION){
File outFile = null;
outFile=fChooser.getSelectedFile();
if (outFile.exists())
JOptionPane.showMessageDialog(null, "FILE ALREADY EXISTS");
else
try{
FileOutputStream fileStream = new FileOutputStream(outFile);
DataOutputStream dataStream = new DataOutputStream(fileStream);
dataStream.writeUTF(t1.getText());
dataStream.writeUTF(t2.getText());
dataStream.writeUTF(t3.getText());
dataStream.writeUTF(t4.getText());
dataStream.writeUTF(t5.getText());
dataStream.writeInt(z.getSelectedIndex());
dataStream.writeInt(k.getSelectedIndex());
dataStream.writeInt(d.getSelectedIndex());
dataStream.writeInt(m.getSelectedIndex());
JLabel mylabel=new JLabel("WELCOME TO STUDENT REGISTRATION SYSTEM");
JLabel l1=new JLabel("EnterName");
JLabel l2=new JLabel("EnterAddress");
JLabel l3=new JLabel("Entertel.phno");
JLabel l4=new JLabel("EnterGender");
JLabel l5=new JLabel("EnterCourse");
JLabel l6=new JLabel("EnterDOB");
JLabel l7=new JLabel("CollegeEntryYear");
JLabel l8=new JLabel("RegNumber");
JLabel l9=new JLabel("HomeDistrict");
JLabel l10=new JLabel("Village");
JLabel l11=new JLabel("T/A");
JLabel l12=new JLabel("NEXT OF KIN DETAILS");
l13=new JLabel("FullName");
JLabel l14=new JLabel("PostalAddress");
JLabel l15=new JLabel("Tel/Cell");
JLabel l16=new JLabel("Email");
fileStream.close();
}
catch(IOException event){
JOptionPane.showMessageDialog(null, "Save with file name");
}
}
}
}
public static void main(String args[])
{
studreg bt=new studreg();
}
void put(int r,int c,int w,int h,Component e)
{
Container cp=this.getContentPane();
cp.setLayout(gl);
gbc.gridx=c;
gbc.gridy=r;
gbc.gridwidth=w;
gbc.gridheight=h;
gbc.insets = new Insets(5, 5, 5, 5);
gl.setConstraints(e,gbc);
cp.add(e);
}
}
No comments:
Post a Comment