Jump to content
Sign in to follow this  
eyda228

Boleh X Tolong Repair?ada Button Yang Xleh Berfungsi>>>

Recommended Posts

(ni tuk daftar class)

import java.awt.*;

import javax.swing.*;

import java.awt.event.*;

import java.io.*;

public class DaftarStudent extends JFrame implements ActionListener

{

private JLabel label1,label2, label3, label4, label5, label6, label7,label8,label9,label10,label11, background;

private JTextField text1, text2, text3, text4, text5, text6, text7, text8;

private JButton button1, button2, button3, button4;

private JPanel panelAtas, panelTengah, panelBawah;

public StafStud data;

public String Name,MatricNum,Faculty, Address, City,State, Postcode, PhoneNum ;

public int semak = 0;

public DaftarStudent()

{

super("Address Book Management System");

Container metal = getContentPane();

metal.setBackground(Color.gray);

metal.setLayout(null);

// Panel Atas

panelAtas = new JPanel();

label1 = new JLabel("STUDENT INFORMATION");

label1.setFont(new Font("ENGRAVERS MT",Font.BOLD,26));

label1.setForeground(Color.black);

// Panel Tengah

panelTengah = new JPanel();

label2 = new JLabel(" Please fill in the blank ");

label3 = new JLabel("");

label4 = new JLabel(" Name ");

text1 = new JTextField(6);

label5 = new JLabel(" Matric No ");

text2 = new JTextField(6);

label6 = new JLabel(" Faculty ");

text3 = new JTextField(6);

label7 = new JLabel(" Address ");

text4 = new JTextField(30);

label8 = new JLabel(" City ");

text5 = new JTextField(30);

label9 = new JLabel(" State ");

text6 = new JTextField(30);

label10 = new JLabel(" Postcode");

text7 = new JTextField(30);

label11 = new JLabel(" Phone No ");

text8 = new JTextField(30);

// Panel Bawah

panelBawah = new JPanel();

button1 = new JButton(" Add ");

button1.addActionListener(this);

button2 = new JButton(" Reset ");

button2.addActionListener(this);

button3 = new JButton(" Back ");

button3.addActionListener(this);

button4 = new JButton(" Exit ");

button4.addActionListener(this);

background = new JLabel(new ImageIcon("BCG3.JPG"));

label1.setBounds (80,30,550,30);

label2.setBounds (100,70,200,30);

label3.setBounds (100,110,300,30);

label4.setBounds (100,130,100,30);

text1.setBounds (180,130,300,30);

label5.setBounds (100,170,100,30);

text2.setBounds (180,170,300,30);

label6.setBounds (100,210,100,30);

text3.setBounds (180,210,300,30);

label7.setBounds (100,250,100,30);

text4.setBounds (180,250,300,30);

label8.setBounds (100,290,100,30);

text5.setBounds (180,290,300,30);

label9.setBounds (100,330,100,30);

text6.setBounds (180,330,300,30);

label10.setBounds (100,370,100,30);

text7.setBounds (180,370,300,30);

label11.setBounds (100,410,100,30);

text8.setBounds (180,410,300,30);

button1.setBounds(100,450,100,30);

button2.setBounds(200,450,100,30);

button3.setBounds(300,450,100,30);

button4.setBounds(400,450,100,30);

background.setBounds (1,1,600,500);

metal.add(label1);

metal.add(label2);

metal.add(label3);

metal.add(label4);

metal.add(text1);

metal.add(label5);

metal.add(text2);

metal.add(label6);

metal.add(text3);

metal.add(label7);

metal.add(text4);

metal.add(label8);

metal.add(text5);

metal.add(label9);

metal.add(text6);

metal.add(label10);

metal.add(text7);

metal.add(label11);

metal.add(text8);

metal.add(button1);

metal.add(button2);

metal.add(button3);

metal.add(button4);

metal.add(background);

setSize(600,530);

setVisible(true);

setResizable(false);

setLocation(300,100);

}

public void actionPerformed(ActionEvent e)

{

Name = text1.getText();

MatricNum = text2.getText();

Faculty = text3.getText();

Address = text4.getText();

City = text5.getText();

State = text6.getText();

Postcode = text7.getText();

PhoneNum= text8.getText();

if (e.getSource() == button1)

{

semakData();

if(semak == 0)

{

if(Name.length()==0||MatricNum.length()==0||Faculty.length()

==0||Address.length()==0||City.length()==0||State.length()==0

||Postcode.length()==0||PhoneNum.length()==0)

{

JOptionPane.showMessageDialog

(this," Please complete any empty column\n\n Thank You"," STUDENT INFORMATION SYSTEM",JOptionPane.INFORMATION_MESSAGE);

}

else

{

DaftarStudent menu = new DaftarStudent();

simpanData();

dispose();

}

}

if(semak != 0)

{

if(Name.equals(Name))

{

JOptionPane.showMessageDialog

(this," This information has being edit!!!\n\n Please insert the new information\n\n Thank You"," STUDENT INFORMATION STORE",JOptionPane.INFORMATION_MESSAGE);

}

}

}

if (e.getSource() == button2)

{

DaftarStudent menu = new DaftarStudent();

dispose();

}

if (e.getSource() == button3)

{

Student Menu = new Student();

dispose();

}

if (e.getSource() == button4)

System.exit(0);

}

public void simpanData()

{

try

{

FileOutputStream write = new FileOutputStream("StudList.txt",true);

PrintStream p = new PrintStream(write);

p.println("Name : "+ Name + "\n");

p.println("Matric No : "+ MatricNum + "\n");

p.println("Faculty : "+ Faculty + "\n");

p.println("Address : "+ Address + "\n");

p.println("City : "+ City +"\n");

p.println("State : "+ State +"\n");

p.println("Postcode : "+ Postcode +"\n");

p.println("Phone Num : "+ PhoneNum + "\n");

p.println("+++++++++++++++++++++++++++++++++++++++++\n");

p.flush();

p.close();

data = new StafStud(Name,MatricNum,Faculty, Address, City, State, Postcode, PhoneNum);

}

catch(IOException s)

{

System.out.println("IOException: " + s.getMessage());

}

}

public void semakData()

{

String ayat;

String pilih = new String("Phone Num : "+ PhoneNum);

try

{

FileReader baca = new FileReader("StudList.txt");

BufferedReader p1 = new BufferedReader(baca);

try

{

while((ayat = p1.readLine()) != null )

{

if (ayat.equalsIgnoreCase(pilih))

semak++;

}

}

catch(IOException e1)

{

System.out.println("IOException: " + e1.getMessage());

}

}

catch(IOException e2)

{

System.out.println("Failed to open file!");

}

}

public static void main(String [] arg)

{

DaftarStudent label = new DaftarStudent();

label.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

}

}

Share this post


Link to post
Share on other sites

(ni tuk delete)

import java.awt.*;

import javax.swing.*;

import java.awt.event.*;

import java.io.*;

public class DaftarStudent extends JFrame implements ActionListener

{

private JLabel label1,label2, label3, label4, label5, label6, label7,label8,label9,label10,label11, background;

private JTextField text1, text2, text3, text4, text5, text6, text7, text8;

private JButton button1, button2, button3, button4;

private JPanel panelAtas, panelTengah, panelBawah;

public StafStud data;

public String Name,MatricNum,Faculty, Address, City,State, Postcode, PhoneNum ;

public int semak = 0;

public DaftarStudent()

{

super("Address Book Management System");

Container metal = getContentPane();

metal.setBackground(Color.gray);

metal.setLayout(null);

// Panel Atas

panelAtas = new JPanel();

label1 = new JLabel("STUDENT INFORMATION");

label1.setFont(new Font("ENGRAVERS MT",Font.BOLD,26));

label1.setForeground(Color.black);

// Panel Tengah

panelTengah = new JPanel();

label2 = new JLabel(" Please fill in the blank ");

label3 = new JLabel("");

label4 = new JLabel(" Name ");

text1 = new JTextField(6);

label5 = new JLabel(" Matric No ");

text2 = new JTextField(6);

label6 = new JLabel(" Faculty ");

text3 = new JTextField(6);

label7 = new JLabel(" Address ");

text4 = new JTextField(30);

label8 = new JLabel(" City ");

text5 = new JTextField(30);

label9 = new JLabel(" State ");

text6 = new JTextField(30);

label10 = new JLabel(" Postcode");

text7 = new JTextField(30);

label11 = new JLabel(" Phone No ");

text8 = new JTextField(30);

// Panel Bawah

panelBawah = new JPanel();

button1 = new JButton(" Add ");

button1.addActionListener(this);

button2 = new JButton(" Reset ");

button2.addActionListener(this);

button3 = new JButton(" Back ");

button3.addActionListener(this);

button4 = new JButton(" Exit ");

button4.addActionListener(this);

background = new JLabel(new ImageIcon("BCG3.JPG"));

label1.setBounds (80,30,550,30);

label2.setBounds (100,70,200,30);

label3.setBounds (100,110,300,30);

label4.setBounds (100,130,100,30);

text1.setBounds (180,130,300,30);

label5.setBounds (100,170,100,30);

text2.setBounds (180,170,300,30);

label6.setBounds (100,210,100,30);

text3.setBounds (180,210,300,30);

label7.setBounds (100,250,100,30);

text4.setBounds (180,250,300,30);

label8.setBounds (100,290,100,30);

text5.setBounds (180,290,300,30);

label9.setBounds (100,330,100,30);

text6.setBounds (180,330,300,30);

label10.setBounds (100,370,100,30);

text7.setBounds (180,370,300,30);

label11.setBounds (100,410,100,30);

text8.setBounds (180,410,300,30);

button1.setBounds(100,450,100,30);

button2.setBounds(200,450,100,30);

button3.setBounds(300,450,100,30);

button4.setBounds(400,450,100,30);

background.setBounds (1,1,600,500);

metal.add(label1);

metal.add(label2);

metal.add(label3);

metal.add(label4);

metal.add(text1);

metal.add(label5);

metal.add(text2);

metal.add(label6);

metal.add(text3);

metal.add(label7);

metal.add(text4);

metal.add(label8);

metal.add(text5);

metal.add(label9);

metal.add(text6);

metal.add(label10);

metal.add(text7);

metal.add(label11);

metal.add(text8);

metal.add(button1);

metal.add(button2);

metal.add(button3);

metal.add(button4);

metal.add(background);

setSize(600,530);

setVisible(true);

setResizable(false);

setLocation(300,100);

}

public void actionPerformed(ActionEvent e)

{

Name = text1.getText();

MatricNum = text2.getText();

Faculty = text3.getText();

Address = text4.getText();

City = text5.getText();

State = text6.getText();

Postcode = text7.getText();

PhoneNum= text8.getText();

if (e.getSource() == button1)

{

semakData();

if(semak == 0)

{

if(Name.length()==0||MatricNum.length()==0||Faculty.length()

==0||Address.length()==0||City.length()==0||State.length()==0

||Postcode.length()==0||PhoneNum.length()==0)

{

JOptionPane.showMessageDialog

(this," Please complete any empty column\n\n Thank You"," STUDENT INFORMATION SYSTEM",JOptionPane.INFORMATION_MESSAGE);

}

else

{

DaftarStudent menu = new DaftarStudent();

simpanData();

dispose();

}

}

if(semak != 0)

{

if(Name.equals(Name))

{

JOptionPane.showMessageDialog

(this," This information has being edit!!!\n\n Please insert the new information\n\n Thank You"," STUDENT INFORMATION STORE",JOptionPane.INFORMATION_MESSAGE);

}

}

}

if (e.getSource() == button2)

{

DaftarStudent menu = new DaftarStudent();

dispose();

}

if (e.getSource() == button3)

{

Student Menu = new Student();

dispose();

}

if (e.getSource() == button4)

System.exit(0);

}

public void simpanData()

{

try

{

FileOutputStream write = new FileOutputStream("StudList.txt",true);

PrintStream p = new PrintStream(write);

p.println("Name : "+ Name + "\n");

p.println("Matric No : "+ MatricNum + "\n");

p.println("Faculty : "+ Faculty + "\n");

p.println("Address : "+ Address + "\n");

p.println("City : "+ City +"\n");

p.println("State : "+ State +"\n");

p.println("Postcode : "+ Postcode +"\n");

p.println("Phone Num : "+ PhoneNum + "\n");

p.println("+++++++++++++++++++++++++++++++++++++++++\n");

p.flush();

p.close();

data = new StafStud(Name,MatricNum,Faculty, Address, City, State, Postcode, PhoneNum);

}

catch(IOException s)

{

System.out.println("IOException: " + s.getMessage());

}

}

public void semakData()

{

String ayat;

String pilih = new String("Phone Num : "+ PhoneNum);

try

{

FileReader baca = new FileReader("StudList.txt");

BufferedReader p1 = new BufferedReader(baca);

try

{

while((ayat = p1.readLine()) != null )

{

if (ayat.equalsIgnoreCase(pilih))

semak++;

}

}

catch(IOException e1)

{

System.out.println("IOException: " + e1.getMessage());

}

}

catch(IOException e2)

{

System.out.println("Failed to open file!");

}

}

public static void main(String [] arg)

{

DaftarStudent label = new DaftarStudent();

label.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

}

}

Share this post


Link to post
Share on other sites

import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import java.io.*;

public class DaftarStudent extends JFrame implements ActionListener
{
	private JLabel label1,label2, label3, label4, label5, label6, label7,label8,label9,label10,label11, background;
	private JTextField text1, text2, text3, text4, text5, text6, text7, text8;
	private JButton button1, button2, button3, button4;
	private JPanel panelAtas, panelTengah, panelBawah;
	public StafStud data;
	public String Name,MatricNum,Faculty, Address, City,State, Postcode, PhoneNum ;
	public int semak = 0;

	public DaftarStudent()
	{
		super("Address Book Management System");
		Container metal = getContentPane();
		metal.setBackground(Color.gray);
		metal.setLayout(null);		

		// Panel Atas
		panelAtas = new JPanel();
		label1 = new JLabel("STUDENT INFORMATION");
		label1.setFont(new Font("ENGRAVERS MT",Font.BOLD,26));   
		label1.setForeground(Color.black);

		// Panel Tengah
		panelTengah = new JPanel();
		label2	= new JLabel(" Please fill in the blank ");
		label3	= new JLabel("");
		label4 	= new JLabel(" Name "); 
		text1 	= new JTextField(6);
		label5 	= new JLabel(" Matric No "); 
		text2 	= new JTextField(6);
		label6 	= new JLabel(" Faculty "); 
		text3 	= new JTextField(6);
		label7 	= new JLabel(" Address "); 
		text4 	= new JTextField(30);
		label8 	= new JLabel(" City "); 
		text5 	= new JTextField(30);
		label9 	= new JLabel(" State "); 
		text6 	= new JTextField(30);
		label10 	= new JLabel(" Postcode"); 
		text7 	= new JTextField(30);
			label11 	= new JLabel(" Phone No "); 
		text8 	= new JTextField(30);



		// Panel Bawah
		panelBawah = new JPanel();
		button1 = new JButton(" Add ");
		button1.addActionListener(this);
		button2 = new JButton(" Reset ");
		button2.addActionListener(this);
		button3 = new JButton(" Back ");
		button3.addActionListener(this);
		button4 = new JButton(" Exit ");
		button4.addActionListener(this);
		background = new JLabel(new ImageIcon("BCG3.JPG"));

		label1.setBounds (80,30,550,30);
		label2.setBounds (100,70,200,30);
		label3.setBounds (100,110,300,30);
		label4.setBounds (100,130,100,30);
		text1.setBounds (180,130,300,30);
		label5.setBounds (100,170,100,30);
		text2.setBounds (180,170,300,30);
		label6.setBounds (100,210,100,30);
		text3.setBounds (180,210,300,30);
		label7.setBounds (100,250,100,30);
		text4.setBounds (180,250,300,30);
		label8.setBounds (100,290,100,30);
		text5.setBounds (180,290,300,30);
		label9.setBounds (100,330,100,30);
		text6.setBounds (180,330,300,30);
			label10.setBounds (100,370,100,30);
		text7.setBounds (180,370,300,30);
	label11.setBounds (100,410,100,30);
		text8.setBounds (180,410,300,30);


		button1.setBounds(100,450,100,30);
		button2.setBounds(200,450,100,30);
		button3.setBounds(300,450,100,30);
		button4.setBounds(400,450,100,30);
		background.setBounds (1,1,600,500);


		metal.add(label1);
		metal.add(label2);
		metal.add(label3);
		metal.add(label4);
		metal.add(text1);
		metal.add(label5);
		metal.add(text2);
		metal.add(label6);
		metal.add(text3);
		metal.add(label7);
		metal.add(text4);
		metal.add(label8);
		metal.add(text5);
			metal.add(label9);
		metal.add(text6);
			metal.add(label10);
		metal.add(text7);
			metal.add(label11);
		metal.add(text8);


		metal.add(button1);
		metal.add(button2);
		metal.add(button3);
		metal.add(button4);
		metal.add(background);

		setSize(600,530);
		setVisible(true);
		setResizable(false);
		setLocation(300,100);
	}

	public void actionPerformed(ActionEvent e)
	{
		Name		= text1.getText();
		MatricNum		= text2.getText();
		Faculty		= text3.getText();
		Address   = text4.getText();
		City	= text5.getText();
		State	= text6.getText();
		Postcode	= text7.getText();
		PhoneNum= text8.getText();


		if (e.getSource()	==	button1)
		{
			semakData();

			if(semak == 0)
			{
				if(Name.length()==0||MatricNum.length()==0||Faculty.length()
==0||Address.length()==0||City.length()==0||State.length()==0
||Postcode.length()==0||PhoneNum.length()==0)
				{
					JOptionPane.showMessageDialog
					(this," Please complete any empty column\n\n Thank You"," STUDENT INFORMATION SYSTEM",JOptionPane.INFORMATION_MESSAGE);
				}
				else
				{
	   			DaftarStudent menu = new DaftarStudent();  		
				simpanData();
				dispose();
				}
			}
			if(semak != 0)
			{
				if(Name.equals(Name))
				{
					JOptionPane.showMessageDialog
					(this,"   This information has being edit!!!\n\n  Please insert the new information\n\n               Thank You","  STUDENT INFORMATION STORE",JOptionPane.INFORMATION_MESSAGE);
				}
			}
		}
		if (e.getSource()	==	button2)
		{
			DaftarStudent menu = new DaftarStudent();
			dispose();
		}
		if (e.getSource()	==	button3)
		{
			Student Menu = new Student();
			dispose();
		}
		if (e.getSource()	==	button4)
			System.exit(0);
	}

	public void simpanData()
	{
		try
		{	
			FileOutputStream write = new FileOutputStream("StudList.txt",true);
			PrintStream p = new PrintStream(write);

			p.println("Name	: "+ Name + "\n");
			p.println("Matric No	: "+ MatricNum + "\n");
			p.println("Faculty	: "+ Faculty + "\n");
			p.println("Address	: "+ Address + "\n");
			p.println("City	: "+ City +"\n");
			p.println("State	: "+ State +"\n");
			p.println("Postcode	: "+ Postcode +"\n");
			p.println("Phone Num	: "+ PhoneNum + "\n");


			p.println("+++++++++++++++++++++++++++++++++++++++++\n");
			p.flush();
			p.close();

			data = new StafStud(Name,MatricNum,Faculty, Address, City, State, Postcode, PhoneNum);
		}

		catch(IOException s)
		{
			System.out.println("IOException: " + s.getMessage());
		}
	}

	public void semakData()
	{
		String ayat;
		String pilih = new String("Phone Num	: "+ PhoneNum);

		try
		{
			FileReader baca = new FileReader("StudList.txt");
			BufferedReader p1 = new BufferedReader(baca);

			try
			{
				while((ayat = p1.readLine()) != null )
				{
					if	(ayat.equalsIgnoreCase(pilih))
						semak++;
				}
			}
			catch(IOException e1)
			{
				System.out.println("IOException: " + e1.getMessage());
			}
		}

		catch(IOException e2)
		{
				System.out.println("Failed to open file!");
		}
	}

	public static void main(String [] arg)
	{
 		DaftarStudent label = new DaftarStudent();
		label.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	}
}

(ni tuk delete)

import java.awt.*;

import javax.swing.*;

import java.awt.event.*;

import java.io.*;

public class DaftarStudent extends JFrame implements ActionListener

{

private JLabel label1,label2, label3, label4, label5, label6, label7,label8,label9,label10,label11, background;

private JTextField text1, text2, text3, text4, text5, text6, text7, text8;

private JButton button1, button2, button3, button4;

private JPanel panelAtas, panelTengah, panelBawah;

public StafStud data;

public String Name,MatricNum,Faculty, Address, City,State, Postcode, PhoneNum ;

public int semak = 0;

public DaftarStudent()

{

super("Address Book Management System");

Container metal = getContentPane();

metal.setBackground(Color.gray);

metal.setLayout(null);

// Panel Atas

panelAtas = new JPanel();

label1 = new JLabel("STUDENT INFORMATION");

label1.setFont(new Font("ENGRAVERS MT",Font.BOLD,26));

label1.setForeground(Color.black);

// Panel Tengah

panelTengah = new JPanel();

label2 = new JLabel(" Please fill in the blank ");

label3 = new JLabel("");

label4 = new JLabel(" Name ");

text1 = new JTextField(6);

label5 = new JLabel(" Matric No ");

text2 = new JTextField(6);

label6 = new JLabel(" Faculty ");

text3 = new JTextField(6);

label7 = new JLabel(" Address ");

text4 = new JTextField(30);

label8 = new JLabel(" City ");

text5 = new JTextField(30);

label9 = new JLabel(" State ");

text6 = new JTextField(30);

label10 = new JLabel(" Postcode");

text7 = new JTextField(30);

label11 = new JLabel(" Phone No ");

text8 = new JTextField(30);

// Panel Bawah

panelBawah = new JPanel();

button1 = new JButton(" Add ");

button1.addActionListener(this);

button2 = new JButton(" Reset ");

button2.addActionListener(this);

button3 = new JButton(" Back ");

button3.addActionListener(this);

button4 = new JButton(" Exit ");

button4.addActionListener(this);

background = new JLabel(new ImageIcon("BCG3.JPG"));

label1.setBounds (80,30,550,30);

label2.setBounds (100,70,200,30);

label3.setBounds (100,110,300,30);

label4.setBounds (100,130,100,30);

text1.setBounds (180,130,300,30);

label5.setBounds (100,170,100,30);

text2.setBounds (180,170,300,30);

label6.setBounds (100,210,100,30);

text3.setBounds (180,210,300,30);

label7.setBounds (100,250,100,30);

text4.setBounds (180,250,300,30);

label8.setBounds (100,290,100,30);

text5.setBounds (180,290,300,30);

label9.setBounds (100,330,100,30);

text6.setBounds (180,330,300,30);

label10.setBounds (100,370,100,30);

text7.setBounds (180,370,300,30);

label11.setBounds (100,410,100,30);

text8.setBounds (180,410,300,30);

button1.setBounds(100,450,100,30);

button2.setBounds(200,450,100,30);

button3.setBounds(300,450,100,30);

button4.setBounds(400,450,100,30);

background.setBounds (1,1,600,500);

metal.add(label1);

metal.add(label2);

metal.add(label3);

metal.add(label4);

metal.add(text1);

metal.add(label5);

metal.add(text2);

metal.add(label6);

metal.add(text3);

metal.add(label7);

metal.add(text4);

metal.add(label8);

metal.add(text5);

metal.add(label9);

metal.add(text6);

metal.add(label10);

metal.add(text7);

metal.add(label11);

metal.add(text8);

metal.add(button1);

metal.add(button2);

metal.add(button3);

metal.add(button4);

metal.add(background);

setSize(600,530);

setVisible(true);

setResizable(false);

setLocation(300,100);

}

public void actionPerformed(ActionEvent e)

{

Name = text1.getText();

MatricNum = text2.getText();

Faculty = text3.getText();

Address = text4.getText();

City = text5.getText();

State = text6.getText();

Postcode = text7.getText();

PhoneNum= text8.getText();

if (e.getSource() == button1)

{

semakData();

if(semak == 0)

{

if(Name.length()==0||MatricNum.length()==0||Faculty.length()

==0||Address.length()==0||City.length()==0||State.length()==0

||Postcode.length()==0||PhoneNum.length()==0)

{

JOptionPane.showMessageDialog

(this," Please complete any empty column\n\n Thank You"," STUDENT INFORMATION SYSTEM",JOptionPane.INFORMATION_MESSAGE);

}

else

{

DaftarStudent menu = new DaftarStudent();

simpanData();

dispose();

}

}

if(semak != 0)

{

if(Name.equals(Name))

{

JOptionPane.showMessageDialog

(this," This information has being edit!!!\n\n Please insert the new information\n\n Thank You"," STUDENT INFORMATION STORE",JOptionPane.INFORMATION_MESSAGE);

}

}

}

if (e.getSource() == button2)

{

DaftarStudent menu = new DaftarStudent();

dispose();

}

if (e.getSource() == button3)

{

Student Menu = new Student();

dispose();

}

if (e.getSource() == button4)

System.exit(0);

}

public void simpanData()

{

try

{

FileOutputStream write = new FileOutputStream("StudList.txt",true);

PrintStream p = new PrintStream(write);

p.println("Name : "+ Name + "\n");

p.println("Matric No : "+ MatricNum + "\n");

p.println("Faculty : "+ Faculty + "\n");

p.println("Address : "+ Address + "\n");

p.println("City : "+ City +"\n");

p.println("State : "+ State +"\n");

p.println("Postcode : "+ Postcode +"\n");

p.println("Phone Num : "+ PhoneNum + "\n");

p.println("+++++++++++++++++++++++++++++++++++++++++\n");

p.flush();

p.close();

data = new StafStud(Name,MatricNum,Faculty, Address, City, State, Postcode, PhoneNum);

}

catch(IOException s)

{

System.out.println("IOException: " + s.getMessage());

}

}

public void semakData()

{

String ayat;

String pilih = new String("Phone Num : "+ PhoneNum);

try

{

FileReader baca = new FileReader("StudList.txt");

BufferedReader p1 = new BufferedReader(baca);

try

{

while((ayat = p1.readLine()) != null )

{

if (ayat.equalsIgnoreCase(pilih))

semak++;

}

}

catch(IOException e1)

{

System.out.println("IOException: " + e1.getMessage());

}

}

catch(IOException e2)

{

System.out.println("Failed to open file!");

}

}

public static void main(String [] arg)

{

DaftarStudent label = new DaftarStudent();

label.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

}

}

Share this post


Link to post
Share on other sites
public class StafStud
{
	private String Name,MatricNum, Faculty, Address, City,State, Postcode, PhoneNum;

	public StafStud(String name, String matricNum, String faculty, String address, String city, String state, String postcode, String phoneNum)
	{
		Name			= name;
		MatricNum			= matricNum;
		Faculty			= faculty;
		Address			= address;
		City			= city;
		State			= state;
		Postcode			= postcode;
		PhoneNum		= phoneNum;
			}

	public String getName()			
	{
		return Name;
	}
	public String getMatricNum()			
	{
		return MatricNum;
	}
public String getFaculty()			
	{
		return Faculty;
	}

	public String getAddress()  		
	{
		return Address;
	}

	public String getCity()				
	{
		return City;
			}
	public String getState()				
	{
		return State;
			}
	public String getPostcode()				
	{
		return Postcode;
			}


	public String getPhoneNum()  		
	{
		return PhoneNum;
	}
}
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import java.io.*;
import java.util.*;
import java.text.*;

class Student extends JFrame implements ActionListener
{
	private JLabel label1, label2, label3, logo1, background;
	private JButton button1, button2, button3, button4, button5;


	public Student()
	{
		super(" ADDRESS BOOK MANAGEMENT SYSTEM ");	
        Container metal = getContentPane();
		metal.setBackground(Color.gray);

		ImageIcon icon1 = new ImageIcon( "uum.gif" );
		logo1 = new JLabel(icon1);
		label1 = new JLabel("UNIVERSITI UTARA MALAYSIA");
		label1.setFont(new Font("Comic Sans MS",Font.BOLD,10));   
		label1.setForeground(Color.black);

		background = new JLabel(new ImageIcon("BCG3.JPG"));

		label2 = new JLabel(" Registeration Menu");
		label2.setFont(new Font("Comic Sans MS",Font.ITALIC,18));   
		label2.setForeground(Color.black);
		label3 = new JLabel("WELCOME TO THE SYSTEM");
		label3.setFont(new Font("SansSerif",Font.BOLD,18));

		button1 = new JButton("Register");
		button1.addActionListener(this);
		button2 = new JButton("Display Student");
		button2.addActionListener(this);
		button3 = new JButton("Search Student");
		button3.addActionListener(this);
		button4 = new JButton("Delete Student");
		button4.addActionListener(this);
			button5 = new JButton("Exit");
		button5.addActionListener(this);			

		logo1.setBounds   (140,30,300,100);
		label1.setBounds  (210,80,400,100);
		label3.setBounds  (170,140,400,100);
		button1.setBounds (220,220,140,30);
		button2.setBounds (220,260,140,30);
		button3.setBounds (220,300,140,30);
		button4.setBounds (220,340,140,30);
		button5.setBounds (220,380,140,30);	
		background.setBounds (1,1,600,500);


		metal.add(logo1);
		metal.add(label1);
		metal.add(label3);		
		metal.add(button1);
		metal.add(button2);
		metal.add(button3);
		metal.add(button4);
			metal.add(button5);			
		metal.add(background);

		setSize(600,510);
		setVisible (true);
		setResizable(true);
		setLocation(300,100);	
	}

	public void actionPerformed(ActionEvent e)
	{
		if (e.getSource()	==	button1)
		{
			DaftarStudent Daftar = new DaftarStudent();
			dispose();
		}
		else if (e.getSource() == button2)
		{
			DisplayAllStud Display = new DisplayAllStud();
			dispose();
		}
		else if (e.getSource()	==	button3)
		{
			SearchSS  Menu = new SearchSS();
			dispose();
		}
		else if (e.getSource()	==	button4)
		{
			Delete  Delete = new Delete();
			dispose();
		}

		else if (e.getSource()	==	button5)
		{
			System.exit(0);

		}
	}

	public static void main(String []args)
   {
 		Student label = new Student();
	  	label.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	}
}
import java.util.Timer;
import java.util.TimerTask;
import javax.swing.JLabel;
import java.util.Calendar;
import java.util.Date;
import java.text.DateFormat;
import javax.swing.JLabel;
import java.awt.*;
import java.awt.event.*;

public class TimerTime
{
	Timer timer;
	Calendar cal;
	Date date;
	DateFormat dateFormatter;

//	Constructor used for running main.
	public TimerTime(boolean visible,JLabel label,int seconds)
	{
		timer = new Timer();
		timer.scheduleAtFixedRate(new DoTime(visible,label),0, seconds*1000);
	}

	public TimerTime(int seconds)
	{
		this(new JLabel(),seconds);
	}
	public TimerTime()
	{
		this(new JLabel(),1);
	}
	public TimerTime(JLabel label)
	{
		this(label, 1);
	}

	public TimerTime(JLabel label, int seconds)
	{
		timer = new Timer();
		timer.scheduleAtFixedRate(new DoTime(label),0, seconds*1000);
	}

	class DoTime extends TimerTask
	{
		JLabel label = new JLabel();
		boolean visible = false;

		public DoTime()
		{
		}
		public DoTime(boolean visible, JLabel label)
		{
			this.label = label;
			this.visible = visible;
		}
		public DoTime(JLabel label)
		{
			this.label = label;
		}
		public void run()
		{
			cal = Calendar.getInstance();
			date = cal.getTime();
			dateFormatter = DateFormat.getTimeInstance();
			label.setText(dateFormatter.format(date));
		}
		public void timerCancel()
		{
			timer.cancel();
		}
	}

	public void timerCancel()
	{
		timer.cancel();
	}
}
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import java.io.*;

public class DaftarStudent extends JFrame implements ActionListener
{
	private JLabel label1,label2, label3, label4, label5, label6, label7,label8,label9,label10,label11, background;
	private JTextField text1, text2, text3, text4, text5, text6, text7, text8;
	private JButton button1, button2, button3, button4;
	private JPanel panelAtas, panelTengah, panelBawah;
	public StafStud data;
	public String Name,MatricNum,Faculty, Address, City,State, Postcode, PhoneNum ;
	public int semak = 0;

	public DaftarStudent()
	{
		super("Address Book Management System");
		Container metal = getContentPane();
		metal.setBackground(Color.gray);
		metal.setLayout(null);		

		// Panel Atas
		panelAtas = new JPanel();
		label1 = new JLabel("STUDENT INFORMATION");
		label1.setFont(new Font("ENGRAVERS MT",Font.BOLD,26));   
		label1.setForeground(Color.black);

		// Panel Tengah
		panelTengah = new JPanel();
		label2	= new JLabel(" Please fill in the blank ");
		label3	= new JLabel("");
		label4 	= new JLabel(" Name "); 
		text1 	= new JTextField(6);
		label5 	= new JLabel(" Matric No "); 
		text2 	= new JTextField(6);
		label6 	= new JLabel(" Faculty "); 
		text3 	= new JTextField(6);
		label7 	= new JLabel(" Address "); 
		text4 	= new JTextField(30);
		label8 	= new JLabel(" City "); 
		text5 	= new JTextField(30);
		label9 	= new JLabel(" State "); 
		text6 	= new JTextField(30);
		label10 	= new JLabel(" Postcode"); 
		text7 	= new JTextField(30);
			label11 	= new JLabel(" Phone No "); 
		text8 	= new JTextField(30);



		// Panel Bawah
		panelBawah = new JPanel();
		button1 = new JButton(" Add ");
		button1.addActionListener(this);
		button2 = new JButton(" Reset ");
		button2.addActionListener(this);
		button3 = new JButton(" Back ");
		button3.addActionListener(this);
		button4 = new JButton(" Exit ");
		button4.addActionListener(this);
		background = new JLabel(new ImageIcon("BCG3.JPG"));

		label1.setBounds (80,30,550,30);
		label2.setBounds (100,70,200,30);
		label3.setBounds (100,110,300,30);
		label4.setBounds (100,130,100,30);
		text1.setBounds (180,130,300,30);
		label5.setBounds (100,170,100,30);
		text2.setBounds (180,170,300,30);
		label6.setBounds (100,210,100,30);
		text3.setBounds (180,210,300,30);
		label7.setBounds (100,250,100,30);
		text4.setBounds (180,250,300,30);
		label8.setBounds (100,290,100,30);
		text5.setBounds (180,290,300,30);
		label9.setBounds (100,330,100,30);
		text6.setBounds (180,330,300,30);
			label10.setBounds (100,370,100,30);
		text7.setBounds (180,370,300,30);
	label11.setBounds (100,410,100,30);
		text8.setBounds (180,410,300,30);


		button1.setBounds(100,450,100,30);
		button2.setBounds(200,450,100,30);
		button3.setBounds(300,450,100,30);
		button4.setBounds(400,450,100,30);
		background.setBounds (1,1,600,500);


		metal.add(label1);
		metal.add(label2);
		metal.add(label3);
		metal.add(label4);
		metal.add(text1);
		metal.add(label5);
		metal.add(text2);
		metal.add(label6);
		metal.add(text3);
		metal.add(label7);
		metal.add(text4);
		metal.add(label8);
		metal.add(text5);
			metal.add(label9);
		metal.add(text6);
			metal.add(label10);
		metal.add(text7);
			metal.add(label11);
		metal.add(text8);


		metal.add(button1);
		metal.add(button2);
		metal.add(button3);
		metal.add(button4);
		metal.add(background);

		setSize(600,530);
		setVisible(true);
		setResizable(false);
		setLocation(300,100);
	}

	public void actionPerformed(ActionEvent e)
	{
		Name		= text1.getText();
		MatricNum		= text2.getText();
		Faculty		= text3.getText();
		Address   = text4.getText();
		City	= text5.getText();
		State	= text6.getText();
		Postcode	= text7.getText();
		PhoneNum= text8.getText();


		if (e.getSource()	==	button1)
		{
			semakData();

			if(semak == 0)
			{
				if(Name.length()==0||MatricNum.length()==0||Faculty.length()
==0||Address.length()==0||City.length()==0||State.length()==0
||Postcode.length()==0||PhoneNum.length()==0)
				{
					JOptionPane.showMessageDialog
					(this," Please complete any empty column\n\n Thank You"," STUDENT INFORMATION SYSTEM",JOptionPane.INFORMATION_MESSAGE);
				}
				else
				{
	   			DaftarStudent menu = new DaftarStudent();  		
				simpanData();
				dispose();
				}
			}
			if(semak != 0)
			{
				if(Name.equals(Name))
				{
					JOptionPane.showMessageDialog
					(this,"   This information has being edit!!!\n\n  Please insert the new information\n\n               Thank You","  STUDENT INFORMATION STORE",JOptionPane.INFORMATION_MESSAGE);
				}
			}
		}
		if (e.getSource()	==	button2)
		{
			DaftarStudent menu = new DaftarStudent();
			dispose();
		}
		if (e.getSource()	==	button3)
		{
			Student Menu = new Student();
			dispose();
		}
		if (e.getSource()	==	button4)
			System.exit(0);
	}

	public void simpanData()
	{
		try
		{	
			FileOutputStream write = new FileOutputStream("StudList.txt",true);
			PrintStream p = new PrintStream(write);

			p.println("Name	: "+ Name + "\n");
			p.println("Matric No	: "+ MatricNum + "\n");
			p.println("Faculty	: "+ Faculty + "\n");
			p.println("Address	: "+ Address + "\n");
			p.println("City	: "+ City +"\n");
			p.println("State	: "+ State +"\n");
			p.println("Postcode	: "+ Postcode +"\n");
			p.println("Phone Num	: "+ PhoneNum + "\n");


			p.println("+++++++++++++++++++++++++++++++++++++++++\n");
			p.flush();
			p.close();

			data = new StafStud(Name,MatricNum,Faculty, Address, City, State, Postcode, PhoneNum);
		}

		catch(IOException s)
		{
			System.out.println("IOException: " + s.getMessage());
		}
	}

	public void semakData()
	{
		String ayat;
		String pilih = new String("Phone Num	: "+ PhoneNum);

		try
		{
			FileReader baca = new FileReader("StudList.txt");
			BufferedReader p1 = new BufferedReader(baca);

			try
			{
				while((ayat = p1.readLine()) != null )
				{
					if	(ayat.equalsIgnoreCase(pilih))
						semak++;
				}
			}
			catch(IOException e1)
			{
				System.out.println("IOException: " + e1.getMessage());
			}
		}

		catch(IOException e2)
		{
				System.out.println("Failed to open file!");
		}
	}

	public static void main(String [] arg)
	{
 		DaftarStudent label = new DaftarStudent();
		label.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	}
}
import java.io.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

public class Delete extends Frame implements ActionListener 
{	

		JLabel label0 = new JLabel("Information  Deleted");
		JLabel label1 = new JLabel("Please Enter Your Phone Number :");

		public Button bmenu = new Button("Menu");
		public Button bhapus = new Button("Delete");
		int i,size,a=0;
		public TextField text1 = new TextField("",8);
		String PhoneNum;
		String [][] data=new String[100][19];
		//String [][] temp=new String[1][19];
		boolean find;

	public Delete()
	{
		setTitle("Address Book Management System");
		setFont(new Font("Times News Roman",Font.BOLD,16));
	 	setBackground(Color.gray);
		setSize(600,300);
	  	setLayout(null);

		add(label0);
      label0.setFont(new Font("Times New Roman",Font.BOLD,29));
		label0.setForeground(Color.blue);
		label0.setBounds(170,50,300,30);

		add(text1);

      add(label1); 
		label1.setFont(new Font("Times New Roman",Font.BOLD,16));
		label1.setForeground(Color.black);
		label1.setBounds(80,120,250,25);
		text1.setBounds(350,120,70,25);

  	   add(bhapus);
	   bhapus.setFont(new Font("Times New Roman",Font.BOLD,12));
	   bhapus.setBackground(Color.white);
	   bhapus.setBounds(120,250,100,30);
	   bhapus.addActionListener(this);

	   add(bmenu);
	   bmenu.setFont(new Font("Times New Roman",Font.BOLD,12));
	   bmenu.setBackground(Color.white);
	   bmenu.setBounds(360,250,100,30);
      bmenu.addActionListener(this);

      addWindowListener(new WindowEventHandler());
      show();
	}

	public void actionPerformed(ActionEvent e) 
	{

		if(e.getSource()==bmenu)
		 {
	  		Student  a = new Student ();
			a.show();
			dispose();
		}

		if(e.getSource()==bhapus)
		 {
	  		if(!text1.getText().equals(""))
		 	{	
		 		PhoneNum=text1.getText();

		 		try
		 		{
		 			FileInputStream streamInput=new FileInputStream("StudList.txt");
					InputStreamReader stream=new InputStreamReader(streamInput);
					BufferedReader read =new BufferedReader(stream);
					StreamTokenizer token=new StreamTokenizer(read);

					token.nextToken();

					//while(token.ttype!=StreamTokenizer.TT_EOF)
				//	{
						for (size=0;size<100;size++)
						{
							if(token.ttype!=StreamTokenizer.TT_EOF)
							{
								System.out.println("III :  "+size);
								for(int x=0;x<19;x++)
								{	
								data[size][x]=token.sval;
								token.nextToken();
								}
							}
							else
							break;
			 	  		}
				//	}



					try
					{
						for(i=0;i<100;i++)
						{
							if(data[i][3].equals(PhoneNum))
							{
								String output="Student Name : "+data[i][0]+"\nThe Student Record Has Been Delete.";
								JOptionPane.showMessageDialog(this,output,"Delete Infomation",JOptionPane.INFORMATION_MESSAGE);
								find=true;

							try
							{	for(a=i;a<size;a++)
								{
									for(int b=0;b<19;b++)
									{
										//temp[1][b]=data[a-1][b];
										data[a][b]=data[a+1][b];
										//System.out.println("b  "+data[a][b]);						

									}
								}

							}	
							catch(ArrayIndexOutOfBoundsException abc )
							{
								for(int b=0;b<19;b++)
								{
									data[a][b]=null;
								System.out.println("a  "+data[a][b]);
								}

							}
							try
							{

								PrintWriter tulisStatus=new PrintWriter(new FileWriter("StudList.txt"));
								for(int r=0;r<size-1;r++)
								{
									for(int s=0;s<19;s++)
									tulisStatus.print("\""+data[r][s]+"\" ");

								}
								tulisStatus.flush();
								tulisStatus.close();

							}
							catch(IOException lll)
							{
								;
							}

								break;
							}
						}
					}
					catch(NullPointerException err)
					{
						;
					}
				}
		 		catch(IOException error)
		 		{
		 			;
		 		}

		 		if(!find)
		 		JOptionPane.showMessageDialog(this,"Cant Find It!!","Infomation",JOptionPane.WARNING_MESSAGE);
					find=false;
		 	}

		 	else
		 	JOptionPane.showMessageDialog(this,"The phone number isn't complete !!",
	 	  	"Infomation",JOptionPane.WARNING_MESSAGE);
		}

	}
   public static void main (String []args) {
		Delete menu = new Delete();

   }
	class WindowEventHandler extends WindowAdapter {
		public void windowClosing(WindowEvent e) {
			System.exit(0);
		}
	} //end class WindowEventHandler

}
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import javax.swing.*;

class DisplayAllStud extends JFrame implements ActionListener
{
	public int allStud;
	private JButton button1,button2;
	private JLabel label1, label2, background ;
	private JTextArea txtArea1;
	private JScrollPane scroll;

	public DisplayAllStud()
	{
		super(" Address Book Management System ");
		Container metal = getContentPane();
		metal.setBackground(Color.gray);

		label1	= new JLabel("THE LIST OF ALL STUDENT");
		label1.setFont(new Font("Georgia",Font.BOLD,20));
		label1.setForeground(Color.blue);
		background = new JLabel(new ImageIcon("BCG3.JPG"));
		txtArea1	= new JTextArea(10,10);
		metal.add(scroll = new JScrollPane(txtArea1));
		button1	= new JButton(" BACK ");
		button1.addActionListener(this);
		button2	= new JButton(" SORT ");
		button2.addActionListener(this);



		label1.setBounds(140,30,730,30);
		scroll.setBounds(120,100,350,300);
		button1.setBounds(120,420,150,30);
		button2.setBounds(280,420,150,30);


		metal.add(label1);
		metal.add(scroll);
		metal.add(button1);
		metal.add(button2);
 		metal.add(background);

		setSize(600,510);
		setLocation(300,100);
		setResizable(true);
		setLayout(null);
		setVisible(true);

		display();
	}

	public void actionPerformed(ActionEvent event)
	{			
		if(event.getSource() == button1)
		{
  			Student menu = new Student();
  			dispose();
  		}
	}

	public void display()
	{
		String ayat;
		int bil=0;
		try
		{
		//to display all student list	
		FileReader baca=new FileReader("StudList.txt");
		BufferedReader p=new BufferedReader(baca);
		try
		{
		while((ayat=p.readLine())!=null)
		{
			txtArea1.append(ayat);
			txtArea1.append("\n");
			bil++;
			}
		}
		catch(IOException e1)
		{
				System.out.println("IOException: "+e1.getMessage());
		}
	}

		catch(IOException e2)
		{
			System.out.println("Failed to open file!");
		}

		allStud = bil;
		label2 = new JLabel("Total Of Student : "+allStud);
		label2.setBounds(120,70,300,30);
		add(label2);

	}

	public static void main(String[]args)
	{
		DisplayAllStud label = new DisplayAllStud();
		label.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	}
}
   import java.awt.*;
   import javax.swing.*;
   import java.awt.event.*;
   import java.io.*;
   import java.util.*;
   import java.text.*;

    public class MenuUtama extends JFrame implements ActionListener
   {
      private JLabel title, title2, background, time1, time2, logo1, logo2, COPYRIGHT;
      private JButton click1, click2, developer;
      private JPanel panelAtas, middlePanel;

       public MenuUtama()
      {
         super(" Address Book Management System ");	
         Container metal = getContentPane();
         metal.setBackground(Color.gray);
         metal.setLayout(null);

      //Upper PaneL
         panelAtas = new JPanel();
         ImageIcon icon1 = new ImageIcon( "" );
         logo1 = new JLabel(icon1);

         title = new JLabel("    UNIVERSITI UTARA MALAYSIA ");
         title.setFont(new Font("Verdana",Font.BOLD,10));
         title2 = new JLabel("    ADDRESS BOOK MANAGEMENT SYSTEM ");
         title2.setFont(new Font("Snap ITC",Font.BOLD,15));
         background = new JLabel(new ImageIcon("BCG3.JPG"));
         COPYRIGHT = new JLabel("Orbit Corp. Copyright Version 2008");

         Date td = new Date();
         String tdate1 = DateFormat.getDateInstance().format(td);
         JLabel time1 = new JLabel(" " + tdate1 + " ");
         time1.setFont(new Font("Goudy Stout",Font.BOLD,14));
         time1.setForeground(Color.red);
         JLabel time2 = new JLabel();
         new TimerTime(time2);

      //Middle Panel
         middlePanel = new JPanel();
         click1	= new JButton(" LOGIN ");
         click1.addActionListener(this);
         click2	= new JButton(" QUIT ");
         click2.addActionListener(this);
         ImageIcon icon2 = new ImageIcon( "Globe.GIF" );
         developer = new JButton(icon2);
         developer.addActionListener(this);
         ImageIcon icon3 = new ImageIcon( "uum.gif" );
         logo2 = new JLabel(icon3);


         title.setBounds (200,140,600,30);
         title2.setBounds (60,180,600,30);			
         time1.setBounds (400,20,250,35);
         time2.setBounds (430,45,100,30);
         click1.setBounds (240,260,100,30);
         click2.setBounds (240,300,100,30);
         logo1.setBounds (140,75,300,35);
         logo2.setBounds (260,10,50,160);
         developer.setBounds (540,434,40,45);		
         COPYRIGHT.setBounds (340,450,600,30);
         background.setBounds (1,1,600,500);

         metal.add(title);
         metal.add(title2);					
         metal.add(time1);
         metal.add(time2);
         metal.add(click1);
         metal.add(click2);
         metal.add(logo1);
         metal.add(developer);
         metal.add(logo2);
         metal.add(COPYRIGHT);	
         metal.add(background);


         setSize(600,510);
         setVisible (true);
         setResizable(false);
         setLocation(300,100);	
      }

       public void actionPerformed(ActionEvent e)
      {
         if (e.getSource()	==	click1)
         {
            Password menu = new Password();
            dispose();
         }
         else if (e.getSource()	==	click2)
         {
            System.exit(0);
         }
         else if (e.getSource()	==	developer)
         {
            SystemDeveloper menu = new SystemDeveloper();
            dispose();
         }
      }

       public static void main(String []args)
      {
         MenuUtama label = new MenuUtama();
         label.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      }
   }


    class SystemDeveloper extends JFrame implements ActionListener
   {
      private JTextArea txtArea1;
      private JLabel title, background;
      private JButton button1;

       public SystemDeveloper()
      {
         super(" STUDENT ADDRESS STORE ");	
         Container metal = getContentPane();
         metal.setBackground(Color.gray);
         metal.setLayout(null);

         title	= new JLabel("System Developer");
         title.setFont(new Font("GOUDYSTO.TTF",Font.BOLD,20));		
         txtArea1 = new JTextArea("\nProject Leader\nSuguna\n\nAssistant\nZuraida\nSuhailee"+"\n");
         txtArea1.setFont(new Font("Georgia",Font.BOLD,15));
         txtArea1.setBackground(Color.gray);				
         background = new JLabel(new ImageIcon("BCG3.JPG"));	
         button1	= new JButton("-=BACK=-");
         button1.addActionListener(this);


         title.setBounds(180,50,300,30);
         txtArea1.setBounds(150,100,300,300);
         background.setBounds (1,1,600,500);
         button1.setBounds(250,410,100,30);


         metal.add(title);
         metal.add(txtArea1);
         metal.add(button1);
         metal.add(background);


         setSize(600,510);
         setVisible (true);
         setResizable(false);
         setLocation(300,100);	
      }

       public void actionPerformed(ActionEvent e)
      {
         if(e.getSource() == button1)
         {
            MenuUtama menu = new MenuUtama();
            dispose();
         }
      }
   }
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

public class Password extends JFrame implements ActionListener
{
	static int gagal = 0;

	JLabel uum = new JLabel("UNIVERSITI UTARA MALAYSIA");
	JLabel sistemmarkah = new JLabel("STUDENT ADDRESS SYSTEM");

  	Button button1 = new Button("   OK   ");
  	Button button2 = new Button(" RESET ");
  	Button button3 = new Button("  BACK ");
  	Button button4 = new Button("LOG OUT");

  	private JPasswordField password = new JPasswordField(7);
	private String pw = "student";   	

  	public Password()
  	{
  		super("Address Book Management System");
    	Container gothic = getContentPane();
    	gothic.setLayout(new BorderLayout());

		// Panel Tengah	
		JPanel pTengah = new JPanel();
		pTengah.setLayout(new FlowLayout(FlowLayout.CENTER, 500,8));

	  	Icon logouum = new ImageIcon( "uum.gif" );         
	  	JLabel logo = new JLabel( "",logouum, SwingConstants.LEFT );        
	  	pTengah.add(logo);
	  	pTengah.add(uum);
	  	sistemmarkah.setFont(new Font("Verdana",Font.BOLD,18));
	  	pTengah.add(sistemmarkah);

    	JLabel masukpass = new JLabel("Please Insert Your Password");
    	pTengah.add("center", masukpass);
    	pTengah.add(password);

    	gothic.add(pTengah, BorderLayout.CENTER);

    	// Panel dalam1
    	JPanel metal1 = new JPanel();
    	metal1.setLayout(new FlowLayout(FlowLayout.CENTER, 5,10));

		metal1.add(button1);
	 	button1.addActionListener(this);

    	metal1.add(button2);
    	button2.addActionListener(this);

	 	metal1.add(button3);
    	button3.addActionListener(this);

    	metal1.add(button4);
    	button4.addActionListener(this);

    	// Panel dalam2
    	JPanel metal2 = new JPanel();
		metal2.setLayout(new FlowLayout(FlowLayout.CENTER, 5,10));

    	JLabel copyright = new JLabel("Orbit Corp.          Copyright Version 2007");
    	metal2.add(copyright);


		// Panel Selatan
		JPanel pSelatan = new JPanel();
		pSelatan.setLayout(new GridLayout(2,1,5,5));

		pSelatan.add(metal1);
		pSelatan.add(metal2);

		gothic.add(pSelatan, BorderLayout.SOUTH);

		setSize(450,350);

		Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
		int screenWidth = screenSize.width;
		int screenHeight = screenSize.height;

		Dimension frameSize = getSize();
		int x = (screenWidth - frameSize.width) / 2;
		int y = (screenHeight - frameSize.height) / 2;

		setLocation(x, y);
    	setVisible(true);
    	setDefaultCloseOperation(EXIT_ON_CLOSE);
  	}

	public void actionPerformed(ActionEvent e)
	{
		if (e.getSource() == button1)
	 	{
			if(password.getText().equals(pw)) 
			{
				Student masukdata	= new Student();
				dispose();
			}

			else
			{
				setVisible(true);
				JOptionPane.showMessageDialog(this," INVALID PASSWORD","Student Information Store System",JOptionPane.WARNING_MESSAGE);
				gagal++;
			}
		}

	 	if (e.getSource() == button2)
		{
			password.setText("");
		}

		if (gagal==3)
		{
			JOptionPane.showMessageDialog(this,"SORRY!!!\nTO MANY ERROR!  ","Student Information Store System",JOptionPane.INFORMATION_MESSAGE);
			System.exit(0);
		}

		if(e.getSource() == button3)
		{
	 		MenuUtama menu = new MenuUtama();
			dispose();
		}

		if(e.getSource() == button4)
		{
	 		System.exit(0);
		}
  	}


	public static void main (String [] args)
	{
		Password frame = new Password();				
	}
}
// end class Projek
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import java.io.*;
import java.util.*;

class SearchSS extends JFrame implements ActionListener
{
	private JPanel panelAtas, panelTengah, panelBawah;
	private JButton button1, button2, button3, button4;
	private JLabel label1, label2, logo1, background;
	private JTextArea txtArea1;
	private JTextField txtField1;
	private JScrollPane studentField;
	public String num;

	public SearchSS()
	{
		super(" Address Book Management System ");
		Container metal = getContentPane();
		metal.setBackground(Color.GRAY);
		metal.setLayout(null);
		background = new JLabel(new ImageIcon("BCG3.JPG"));

		//PanelAtas
		panelAtas = new JPanel();
		ImageIcon icon1 = new ImageIcon( "Globe.gif" );
		logo1 = new JLabel(icon1);

		label1 = new JLabel("FIND & SHOW YOUR INFORMATION PERSON");
		label1.setFont(new Font("Georgia",Font.BOLD,20));
		label1.setForeground(Color.blue);

		//Panel Tengah
		panelTengah = new JPanel();
		label2 	= new JLabel(" Phone Num ");
  		txtField1= new JTextField();
		txtField1.addActionListener(this);
		button1 	= new JButton(" Search ");
  		button1.addActionListener(this);
		button2 	= new JButton(" Reset ");
		button2.addActionListener(this);
		txtArea1 = new JTextArea(10,10);
		metal.add(studentField = new JScrollPane(txtArea1));

		//Panel Bawah
		panelBawah = new JPanel();		
  		button3 	= new JButton(" Back ");
		button3.addActionListener(this);
		button4	= new JButton(" Exit ");
  		button4.addActionListener(this);

		logo1.setBounds(10,20,50,50);
  		label1.setBounds(80,30,800,30);
  		label2.setBounds(40,70,100,30);
  		txtField1.setBounds(120,70,100,30);
  		button1.setBounds(230,70,100,30);
		button2.setBounds(340,70,100,30);
		studentField.setBounds(120,110,320,300);
  		button3.setBounds(230,420,100,30);
	 	button4.setBounds(340,420,100,30);
		background.setBounds (1,1,600,500);

		metal.add(logo1);
		metal.add(label1);
		metal.add(label2);
		metal.add(txtField1);
		metal.add(button1);
		metal.add(button2);
		metal.add(studentField);
		metal.add(button3);
		metal.add(button4);
		metal.add(background);

		setSize(600,510);
		setVisible (true);
		setResizable(true);
		setLocation(300,100);	
	}

	public void actionPerformed(ActionEvent event)
	{
		num = txtField1.getText();

		if(event.getSource() == button1)
		{
			papar();
			txtField1.setText("");
  		}

  		if(event.getSource() == button2)
		{
  			txtField1.setText("");
  			txtArea1.setText("");
		}

		if(event.getSource() == button3)
		{
  			Student Menu = new Student();
  			dispose();
  		}
		if(event.getSource() == button4)
			System.exit(0);
	}

	public void papar()
	{
		String ayat;
		try
		{
			FileReader baca = new FileReader("StudList.txt");
			BufferedReader p1 = new BufferedReader(baca);
			try
			{
				int uji = 0;
				String temp = null;
				String pilih = "Phone Num	: "+ num;
				while((ayat = p1.readLine()) != null)
				{
					if(ayat.equalsIgnoreCase(pilih))
					{
						temp = ayat;

					 	txtArea1.append("");
						txtArea1.append(temp);
						txtArea1.append("\n");

						uji++;

						for(int a=0; a<6; a++)
						{								  
							String temp1 = p1.readLine();
						  	txtArea1.append(temp1); 	
					  		txtArea1.append("\n");
						}
					}					
				}
				if(uji==0)
					JOptionPane.showMessageDialog
					(this," NO RELATED DATA "," ERROR",JOptionPane.ERROR_MESSAGE);
			}

			catch(IOException e1)
			{
				System.out.println("IOException: "+e1.getMessage());
			}
		}

		catch(IOException e2)
		{
			txtArea1.append("SORRY!!! NO FILE SUCCEDD TO OPEN\n");
			txtArea1.append("================================\n");
		}
	}


  	public static void main(String[]args)
  	{
		SearchSS label = new SearchSS();
		label.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	}
}

Share this post


Link to post
Share on other sites

Mantap ahhh program ni.

Ada add, search, delete, display and list student disimpan dalam txt.

Okay setakat ni aku jumpa 3 error/problem/bug.

1- Waktu display all student: nape bilangan student sampai 18? padahal aku baru add 1 student.

2- Waktu display all student: sort button tak jalan, sort button tu sort by apa?

3- Delete: tak jalan walaupun masukkan no phone yang betul

last sekali, nape nak kena jadikan phone sebagai primary key? patut metric no kan?

solution untuk 1: baca comment

public void display() {
        String ayat;
        int bil = 0;
        try {
            //to display all student list    
            FileReader baca = new FileReader("StudList.txt");
            BufferedReader p = new BufferedReader(baca);
            try {
                while ((ayat = p.readLine()) != null) {
                    txtArea1.append(ayat);
                    txtArea1.append("\n");
                    bil++; //kalau nak buat gak pengiraan camni, bil kat bawah tu kena bagai 18
                }
            } catch (IOException e1) {
                System.out.println("IOException: " + e1.getMessage());
            }
        } catch (IOException e2) {
            System.out.println("Failed to open file!");
        }

        allStud = bil / 18; //buat pembahagian camni
        label2 = new JLabel("Total Of Student : " + allStud);
        label2.setBounds(120, 70, 300, 30);
        add(label2);

Share this post


Link to post
Share on other sites

sy nak sort by name tapi xtau camne nak buat???

yang delete button tu lecturer nak delete by phone no or name...

>>yang bilangan student tu sy pun xtau camne bleh jd 18 padahal nak wat 1 je...

tolong la sy... :(

Share this post


Link to post
Share on other sites

button tu kena read balik semua list dari .txt tu, pastu sort.

delete tu pun sama, read dulu dari .txt, pastu delete list yg terpilih, pastu save balik dalam .txt.

bilangan tu dah ok dah. cuba baca comment saya kat dalam code tu.

jadi 18 sebab you dah buat pengiraan untuk semua line kat list tu.

so satu student ada 9 data. pastu lepas setiap data ada /n

so 9 data + 9 /n = 18 lines.

nanti saya tolong lagi k :D

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...