hi all, this is my first time using JAVA. i know other programming languages, such as, c++, PHP, Assembly.
this is a basic personal schedular. for saving the data i am using a custom designed linked list, and for the gui i am using custom gui.
the program runs fine as long as i press any button and not enter any data. when i go to the manage appointments section and then insert data in the appointments section, the program crashes when i press any button on the gui.
my liked list is fine and is saving the data. i think it is a memory problem.
i am using netbeans 6.7.
following is my system's info,
intel petium M processor 1.67 ghz 0.99 gb of ram
i am running windows xp home edition.
is it that my notebook does not have enough memory or is the program that is causing the problem.
i feel that it is the way that i am building the gui. whenever my actionPerformed function is called i am creating new objects for every gui page. i think the problem lies here because there is memory leakage, and when i insert my data in the linked list which uses more memory, hence my program crashes. however i do not recieve any out of memory error, however i have noticed that in my task manager when teh program crashes my cpu levels go up to 100%.
also netbeans is using 200+ kb worth of memory.
please help me, i really need to know if i am programming the gui properly.
thanx in advance
the following is the list class.
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author Mustafa Neguib
*/
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
class List extends JFrame implements ActionListener {
//**************************GUI data members***************************
/**
* Default frame width
*/
private static final int FRAME_WIDTH = 640;
/**
* Default frame height
*/
private static final int FRAME_HEIGHT = 480;
/**
* X coordinate of the frame default origin point
*/
private static final int FRAME_X_ORIGIN = 150;
/**
* Y coordinate of the frame default origin point
*/
private static final int FRAME_Y_ORIGIN = 250;
private static final int BUTTON_WIDTH = 80;
private static final int BUTTON_HEIGHT = 30;
private static final String NEWLINE=System.getProperty("line.seperator");
private JButton cancelButton;
private JButton okButton;
private JButton nextButton;
private JButton appointmentsButton;
private JButton toDoButton;
private JButton memoButton;
private static int type;
private JTextField inputLine1;
private JTextField inputLine2;
private JTextField inputLine3;
//************************************************************
//*****************Program data members**********************
private static Node root;
//***********************************************************
public static void main(String[] args)
{
type=0;
List frame=new List();
frame.setVisible(true);
}//end function main
public List()
{
root=null;
Container contentPane= getContentPane();
JPanel title;
JPanel info;
JPanel info1;
JPanel buttons;
JMenu fileMenu;
JMenuItem item;
//************************Build Menus******************************************
//****************************Build File Menu****************
fileMenu= new JMenu("File");
item= new JMenuItem("Main Menu");
item.addActionListener(this);
fileMenu.add(item);
item= new JMenuItem("Exit Software");
item.addActionListener(this);
fileMenu.add(item);
//***********************************
JMenuBar menuBar= new JMenuBar();
setJMenuBar(menuBar);
menuBar.add(fileMenu);
//***************************************************************************
setSize(FRAME_WIDTH,FRAME_HEIGHT);
setResizable(false);
setTitle("Personal Scheduler");
setLocation(FRAME_X_ORIGIN,FRAME_Y_ORIGIN);
contentPane.setLayout(new GridLayout(5,1));
title = new JPanel();
title.add(new JLabel("MN Tech Solutions Personal Scheduler" ));
info = new JPanel();
info.add(new JLabel("Programmer\\Developer: Mustafa Neguib"));
info.add(new JLabel(" "));
info1=new JPanel();
info1.add(new JLabel("Copyright 2009 MN Tech Solutions"));
contentPane.add(title,BorderLayout.NORTH);
contentPane.add(info,BorderLayout.CENTER);
contentPane.add(info1,BorderLayout.CENTER);
buttons= new JPanel();
buttons.add(okButton= new JButton("Start Software"));
buttons.add(cancelButton= new JButton("Exit Software"));
cancelButton.addActionListener(this);
okButton.addActionListener(this);
contentPane.add(buttons,BorderLayout.SOUTH);
//register 'Exit upon closing' as a default close operation
setDefaultCloseOperation( EXIT_ON_CLOSE );
}//end constructor
public List(int type)
{
if(type==1)
{
Container contentPane= getContentPane();
JPanel info;
JPanel buttons1;
JPanel buttons2;
JPanel buttons3;
JMenu fileMenu;
JMenuItem item;
//************************Build Menus******************************************
//****************************Build File Menu****************
fileMenu= new JMenu("File");
item= new JMenuItem("Main Menu");
item.addActionListener(this);
fileMenu.add(item);
item= new JMenuItem("Exit Software");
item.addActionListener(this);
fileMenu.add(item);
//***********************************
JMenuBar menuBar= new JMenuBar();
setJMenuBar(menuBar);
menuBar.add(fileMenu);
//***************************************************************************
setSize(FRAME_WIDTH,FRAME_HEIGHT);
setResizable(false);
setTitle("Personal Scheduler");
setLocation(FRAME_X_ORIGIN,FRAME_Y_ORIGIN);
contentPane.setLayout(new GridLayout(4,1));
info = new JPanel();
info.add(new JLabel("Main Menu"));
contentPane.add(info,BorderLayout.CENTER);
buttons1= new JPanel();
buttons2= new JPanel();
buttons3= new JPanel();
buttons1.add(appointmentsButton= new JButton("Manage Appointments"));
buttons2.add(toDoButton= new JButton("Manage To Do List"));
buttons3.add(memoButton= new JButton("Manage Memos"));
appointmentsButton.addActionListener(this);
toDoButton.addActionListener(this);
memoButton.addActionListener(this);
contentPane.add(buttons1,BorderLayout.SOUTH);
contentPane.add(buttons2,BorderLayout.SOUTH);
contentPane.add(buttons3,BorderLayout.SOUTH);
//register 'Exit upon closing' as a default close operation
setDefaultCloseOperation( EXIT_ON_CLOSE );
}//end if
else if(type==2)
{
Container contentPane= getContentPane();
JPanel info;
JPanel buttons;
JButton buttons1;
JButton buttons2;
JButton buttons3;
JPanel menu;
JMenu fileMenu;
JMenuItem item;
String content1;
//************************Build Menus******************************************
//****************************Build File Menu****************
fileMenu= new JMenu("File");
item= new JMenuItem("Main Menu");
item.addActionListener(this);
fileMenu.add(item);
item= new JMenuItem("Exit Software");
item.addActionListener(this);
fileMenu.add(item);
//***********************************
JMenuBar menuBar= new JMenuBar();
setJMenuBar(menuBar);
menuBar.add(fileMenu);
//***************************************************************************
setSize(FRAME_WIDTH,FRAME_HEIGHT);
setResizable(false);
setTitle("Personal Scheduler");
setLocation(FRAME_X_ORIGIN,FRAME_Y_ORIGIN);
contentPane.setLayout(new BorderLayout(4,2));
menu=new JPanel();
JPanel newPanel;
newPanel= new JPanel();
newPanel.setLayout(new GridLayout(10,0));
menu.setLayout(new BorderLayout(5,1));
newPanel.add(new JLabel(" "));
menu.add(newPanel);
menu.setBorder(BorderFactory.createLoweredBevelBorder());
newPanel.add(buttons1=new JButton("Manage Appointments"));
menu.add(newPanel);
newPanel.add(buttons2=new JButton("Manage To Do List"));
menu.add(newPanel);
newPanel.add(buttons3=new JButton("Manage Memo"));
menu.add(newPanel);
buttons1.addActionListener(this);
buttons2.addActionListener(this);
buttons3.addActionListener(this);
contentPane.add(menu,BorderLayout.EAST);
info = new JPanel();
info.setBorder(BorderFactory.createTitledBorder("Appointments"));
//**********************************get content from the node**********************************
Node ptr;
content1=new String();
content1=" ";
if(root==null)
{//no node exists
content1="No appointments exist.";
}//end if
else
{//print all nodes
ptr=root;
content1="<html>";
while(ptr!=null)
{
if(ptr.typeOfData==1)
{
content1=content1+"Person: "+ptr.namePerson+"<br>"+"Place: "+ptr.place+"<br>"+"Date: "+ptr.date+"<br><br><br>";
ptr=ptr.next;
}//end if
}//end while
//JOptionPane.showMessageDialog(null,content1);
content1=content1+"</html>";
}//end else
//***************************************************************************************
info.add(new JLabel(content1));
JScrollPane scrollText=new JScrollPane(info);
scrollText.setSize(200,135);
contentPane.add(scrollText,BorderLayout.CENTER);
buttons= new JPanel();
buttons.add(okButton= new JButton("Add a new item"));
okButton.addActionListener(this);
contentPane.add(buttons,BorderLayout.SOUTH);
//register 'Exit upon closing' as a default close operation
setDefaultCloseOperation( EXIT_ON_CLOSE );
}//end else if
else if(type==3)
{
Container contentPane= getContentPane();
JPanel info;
JPanel buttons;
JButton buttons1;
JButton buttons2;
JButton buttons3;
JPanel menu;
JMenu fileMenu;
JMenuItem item;
StringBuffer content;
String content1;
//************************Build Menus******************************************
//****************************Build File Menu****************
fileMenu= new JMenu("File");
item= new JMenuItem("Main Menu");
item.addActionListener(this);
fileMenu.add(item);
item= new JMenuItem("Exit Software");
item.addActionListener(this);
fileMenu.add(item);
//***********************************
JMenuBar menuBar= new JMenuBar();
setJMenuBar(menuBar);
menuBar.add(fileMenu);
//***************************************************************************
setSize(FRAME_WIDTH,FRAME_HEIGHT);
setResizable(false);
setTitle("Personal Scheduler");
setLocation(FRAME_X_ORIGIN,FRAME_Y_ORIGIN);
contentPane.setLayout(new BorderLayout(4,2));
menu=new JPanel();
JPanel newPanel;
newPanel= new JPanel();
newPanel.setLayout(new GridLayout(10,0));
menu.setLayout(new BorderLayout(5,1));
newPanel.add(new JLabel(" "));
menu.add(newPanel);
menu.setBorder(BorderFactory.createLoweredBevelBorder());
newPanel.add(buttons1=new JButton("Manage Appointments"));
menu.add(newPanel);
newPanel.add(buttons2=new JButton("Manage To Do List"));
menu.add(newPanel);
newPanel.add(buttons3=new JButton("Manage Memo"));
menu.add(newPanel);
buttons1.addActionListener(this);
buttons2.addActionListener(this);
buttons3.addActionListener(this);
contentPane.add(menu,BorderLayout.EAST);
info = new JPanel();
info.setBorder(BorderFactory.createTitledBorder("To Do List"));
//**********************************get content from the node**********************************
Node ptr;
content1=new String();
content1=" ";
if(root==null)
{//no node exists
content1="No items exist.";
}//end if
else
{//print all nodes
ptr=root;
content1="<html>";
while(ptr!=null)
{
if(ptr.typeOfData==2)
{
content1=content1+"Item: "+ptr.toDoText+"<br><br>";
ptr=ptr.next;
}//end if
}//end while
//JOptionPane.showMessageDialog(null,content1);
content1=content1+"</html>";
}//end else
//***************************************************************************************
info.add(new JLabel(content1));
JScrollPane scrollText=new JScrollPane(info);
scrollText.setSize(200,135);
contentPane.add(scrollText,BorderLayout.CENTER);
buttons= new JPanel();
buttons.add(okButton= new JButton("Add a new item"));
okButton.addActionListener(this);
contentPane.add(buttons,BorderLayout.SOUTH);
//register 'Exit upon closing' as a default close operation
setDefaultCloseOperation( EXIT_ON_CLOSE );
}//end else if
else if(type==4)
{
Container contentPane= getContentPane();
JPanel info;
JPanel buttons;
JButton buttons1;
JButton buttons2;
JButton buttons3;
JPanel menu;
JMenu fileMenu;
JMenuItem item;
StringBuffer content;
String content1;
//************************Build Menus******************************************
//****************************Build File Menu****************
fileMenu= new JMenu("File");
item= new JMenuItem("Main Menu");
item.addActionListener(this);
fileMenu.add(item);
item= new JMenuItem("Exit Software");
item.addActionListener(this);
fileMenu.add(item);
//***********************************
JMenuBar menuBar= new JMenuBar();
setJMenuBar(menuBar);
menuBar.add(fileMenu);
//***************************************************************************
setSize(FRAME_WIDTH,FRAME_HEIGHT);
setResizable(false);
setTitle("Personal Scheduler");
setLocation(FRAME_X_ORIGIN,FRAME_Y_ORIGIN);
contentPane.setLayout(new BorderLayout(4,2));
menu=new JPanel();
JPanel newPanel;
newPanel= new JPanel();
newPanel.setLayout(new GridLayout(10,0));
menu.setLayout(new BorderLayout(5,1));
newPanel.add(new JLabel(" "));
menu.add(newPanel);
menu.setBorder(BorderFactory.createLoweredBevelBorder());
newPanel.add(buttons1=new JButton("Manage Appointments"));
menu.add(newPanel);
newPanel.add(buttons2=new JButton("Manage To Do List"));
menu.add(newPanel);
newPanel.add(buttons3=new JButton("Manage Memo"));
menu.add(newPanel);
buttons1.addActionListener(this);
buttons2.addActionListener(this);
buttons3.addActionListener(this);
contentPane.add(menu,BorderLayout.EAST);
info = new JPanel();
info.setBorder(BorderFactory.createTitledBorder("Memos"));
//**********************************get content from the node**********************************
Node ptr;
content1=new String();
content1=" ";
if(root==null)
{//no node exists
content1="No memos exist.";
}//end if
else
{//print all nodes
ptr=root;
content1="<html>";
while(ptr!=null)
{
if(ptr.typeOfData==3)
{
content1=content1+"Memo: "+ptr.memoText+"<br><br>";
ptr=ptr.next;
}//end if
}//end while
//JOptionPane.showMessageDialog(null,content1);
content1=content1+"</html>";
}//end else
//***************************************************************************************
info.add(new JLabel(content1));
JScrollPane scrollText=new JScrollPane(info);
scrollText.setSize(200,135);
contentPane.add(scrollText,BorderLayout.CENTER);
buttons= new JPanel();
buttons.add(okButton= new JButton("Add a new item"));
okButton.addActionListener(this);
contentPane.add(buttons,BorderLayout.SOUTH);
//register 'Exit upon closing' as a default close operation
setDefaultCloseOperation( EXIT_ON_CLOSE );
}//end else if
else if(type==5)
{
Container contentPane= getContentPane();
JPanel info;
JPanel buttons;
JButton buttons1;
JButton buttons2;
JButton buttons3;
JPanel menu;
JPanel insertPanel1;
JPanel insertPanel2;
JPanel insertPanel3;
JMenu fileMenu;
JMenuItem item;
StringBuffer content;
String content1;
//************************Build Menus******************************************
//****************************Build File Menu****************
fileMenu= new JMenu("File");
item= new JMenuItem("Main Menu");
item.addActionListener(this);
fileMenu.add(item);
item= new JMenuItem("Exit Software");
item.addActionListener(this);
fileMenu.add(item);
//***********************************
JMenuBar menuBar= new JMenuBar();
setJMenuBar(menuBar);
menuBar.add(fileMenu);
//***************************************************************************
setSize(FRAME_WIDTH,FRAME_HEIGHT);
setResizable(false);
setTitle("Personal Scheduler");
setLocation(FRAME_X_ORIGIN,FRAME_Y_ORIGIN);
contentPane.setLayout(new BorderLayout(12,2));
menu=new JPanel();
JPanel newPanel;
newPanel= new JPanel();
newPanel.setLayout(new GridLayout(10,0));
menu.setLayout(new BorderLayout(5,1));
newPanel.add(new JLabel(" "));
menu.add(newPanel);
menu.setBorder(BorderFactory.createLoweredBevelBorder());
newPanel.add(buttons1=new JButton("Manage Appointments"));
menu.add(newPanel);
newPanel.add(buttons2=new JButton("Manage To Do List"));
menu.add(newPanel);
newPanel.add(buttons3=new JButton("Manage Memo"));
menu.add(newPanel);
buttons1.addActionListener(this);
buttons2.addActionListener(this);
buttons3.addActionListener(this);
contentPane.add(menu,BorderLayout.EAST);
info = new JPanel();
contentPane.add(info,BorderLayout.NORTH);
JPanel insertContent;
insertContent= new JPanel();
insertContent.setLayout(new GridLayout(3,1));
inputLine1=new JTextField();
inputLine1.setColumns(22);
inputLine2=new JTextField();
inputLine2.setColumns(22);
inputLine3=new JTextField();
inputLine3.setColumns(22);
inputLine1.addActionListener(this);
inputLine2.addActionListener(this);
inputLine3.addActionListener(this);
insertPanel1=new JPanel();
insertPanel2=new JPanel();
insertPanel3=new JPanel();
insertPanel1.add(new JLabel("Person: "));
insertPanel1.add(inputLine1);
insertPanel2.add(new JLabel("Place: "));
insertPanel2.add(inputLine2);
insertPanel3.add(new JLabel("Date: "));
insertPanel3.add(inputLine3);
insertContent.add(insertPanel1);
insertContent.add(insertPanel2);
insertContent.add(insertPanel3);
contentPane.add(insertContent,BorderLayout.CENTER);
buttons= new JPanel();
buttons.add(okButton= new JButton("Add a new item"));
okButton.addActionListener(this);
contentPane.add(buttons,BorderLayout.SOUTH);
//register 'Exit upon closing' as a default close operation
setDefaultCloseOperation( EXIT_ON_CLOSE );
}//end else if
else if(type==6)
{
}//end else if
else if(type==7)
{
}//end else if
}//end constructor
public void actionPerformed(ActionEvent event)
{
List frame1=new List(1);
List frame2=new List(2);
List frame3=new List(3);
List frame4=new List(4);
List frame5=new List(5);
List frame6=new List(6);
List frame7=new List(7);
//*******************Get the menu action***********************
String menuName;
menuName = event.getActionCommand();
if (menuName.equals("Exit Software")) {
System.exit(0);
}//end if
else if(menuName.equals("Main Menu"))
{
type=1;
frame2.setVisible(false);
frame3.setVisible(false);
frame4.setVisible(false);
frame5.setVisible(false);
frame6.setVisible(false);
frame7.setVisible(false);
setVisible(false);
frame1.setVisible(true);
}//end else if
//****************************************************************
//*******************Get the buttons action********************
JButton clickedButton;
String buttonText;
switch(type)
{
case 0:
clickedButton= (JButton) event.getSource();
buttonText=clickedButton.getText();
if( buttonText.equals("Start Software"))
{//go to the main menu
type=1;
frame2.setVisible(false);
frame3.setVisible(false);
frame4.setVisible(false);
frame5.setVisible(false);
frame6.setVisible(false);
frame7.setVisible(false);
setVisible(false);
frame1.setVisible(true);
}//end if
else if(buttonText.equals("Exit Software"))
{
System.exit(0);
}//end else
break;
case 1:
clickedButton= (JButton) event.getSource();
buttonText=clickedButton.getText();
if( buttonText.equals("Manage Appointments"))
{//go to the main menu
type=2;
frame1.setVisible(false);
frame3.setVisible(false);
frame4.setVisible(false);
frame5.setVisible(false);
frame6.setVisible(false);
frame7.setVisible(false);
setVisible(false);
frame2.setVisible(true);
}//end if
else if(buttonText.equals("Manage To Do List"))
{
type=3;
frame1.setVisible(false);
frame4.setVisible(false);
frame5.setVisible(false);
frame6.setVisible(false);
frame7.setVisible(false);
setVisible(false);
frame2.setVisible(false);
frame3.setVisible(true);
}//end else if
else if(buttonText.equals("Manage Memos"))
{
type=4;
frame1.setVisible(false);
frame4.setVisible(true);
frame5.setVisible(false);
frame6.setVisible(false);
frame7.setVisible(false);
setVisible(false);
frame2.setVisible(false);
frame3.setVisible(false);
}//end else if
break;
case 2:
clickedButton= (JButton) event.getSource();
buttonText=clickedButton.getText();
if( buttonText.equals("Manage Appointments"))
{//go to the main menu
type=2;
frame1.setVisible(false);
frame3.setVisible(false);
frame4.setVisible(false);
frame5.setVisible(false);
frame6.setVisible(false);
frame7.setVisible(false);
setVisible(false);
frame2.setVisible(true);
}//end if
else if(buttonText.equals("Manage To Do List"))
{
type=3;
frame1.setVisible(false);
frame4.setVisible(false);
frame5.setVisible(false);
frame6.setVisible(false);
frame7.setVisible(false);
setVisible(false);
frame2.setVisible(false);
frame3.setVisible(true);
}//end else if
else if(buttonText.equals("Manage Memo"))
{
type=4;
frame1.setVisible(false);
frame4.setVisible(true);
frame5.setVisible(false);
frame6.setVisible(false);
frame7.setVisible(false);
setVisible(false);
frame2.setVisible(false);
frame3.setVisible(false);
}//end else if
else if(buttonText.equals("Add a new item"))
{
type=5;
frame1.setVisible(false);
frame4.setVisible(false);
frame5.setVisible(true);
frame6.setVisible(false);
frame7.setVisible(false);
setVisible(false);
frame2.setVisible(false);
frame3.setVisible(false);
}//end else if
break;
case 3:
clickedButton= (JButton) event.getSource();
buttonText=clickedButton.getText();
if( buttonText.equals("Manage Appointments"))
{//go to the main menu
type=2;
frame1.setVisible(false);
frame3.setVisible(false);
frame4.setVisible(false);
frame5.setVisible(false);
frame6.setVisible(false);
frame7.setVisible(false);
setVisible(false);
frame2.setVisible(true);
}//end if
else if(buttonText.equals("Manage To Do List"))
{
type=3;
frame1.setVisible(false);
frame4.setVisible(false);
frame5.setVisible(false);
frame6.setVisible(false);
frame7.setVisible(false);
setVisible(false);
frame2.setVisible(false);
frame3.setVisible(true);
}//end else if
else if(buttonText.equals("Manage Memo"))
{
type=4;
frame1.setVisible(false);
frame4.setVisible(true);
frame5.setVisible(false);
frame6.setVisible(false);
frame7.setVisible(false);
setVisible(false);
frame2.setVisible(false);
frame3.setVisible(false);
}//end else if
else if(buttonText.equals("Add a new item"))
{
type=6;
frame1.setVisible(false);
frame4.setVisible(false);
frame5.setVisible(false);
frame6.setVisible(true);
frame7.setVisible(false);
setVisible(false);
frame2.setVisible(false);
frame3.setVisible(false);
}//end else if
break;
case 4:
clickedButton= (JButton) event.getSource();
buttonText=clickedButton.getText();
if( buttonText.equals("Manage Appointments"))
{//go to the main menu
type=2;
frame1.setVisible(false);
frame3.setVisible(false);
frame4.setVisible(false);
frame5.setVisible(false);
frame6.setVisible(false);
frame7.setVisible(false);
setVisible(false);
frame2.setVisible(true);
}//end if
else if(buttonText.equals("Manage To Do List"))
{
type=3;
frame1.setVisible(false);
frame4.setVisible(false);
frame5.setVisible(false);
frame6.setVisible(false);
frame7.setVisible(false);
setVisible(false);
frame2.setVisible(false);
frame3.setVisible(true);
}//end else if
else if(buttonText.equals("Manage Memo"))
{
type=4;
frame1.setVisible(false);
frame4.setVisible(true);
frame5.setVisible(false);
frame6.setVisible(false);
frame7.setVisible(false);
setVisible(false);
frame2.setVisible(false);
frame3.setVisible(false);
}//end else if
else if(buttonText.equals("Add a new item"))
{
type=7;
frame1.setVisible(false);
frame4.setVisible(false);
frame5.setVisible(false);
frame6.setVisible(false);
frame7.setVisible(true);
setVisible(false);
frame2.setVisible(false);
frame3.setVisible(false);
}//end else if
break;
case 5:
clickedButton= (JButton) event.getSource();
buttonText=clickedButton.getText();
if( buttonText.equals("Manage Appointments"))
{//go to the main menu
type=2;
frame1.setVisible(false);
frame3.setVisible(false);
frame4.setVisible(false);
frame5.setVisible(false);
frame6.setVisible(false);
frame7.setVisible(false);
setVisible(false);
frame2.setVisible(true);
}//end if
else if(buttonText.equals("Manage To Do List"))
{
type=3;
frame1.setVisible(false);
frame4.setVisible(false);
frame5.setVisible(false);
frame6.setVisible(false);
frame7.setVisible(false);
setVisible(false);
frame2.setVisible(false);
frame3.setVisible(true);
}//end else if
else if(buttonText.equals("Manage Memo"))
{
type=4;
frame1.setVisible(false);
frame4.setVisible(true);
frame5.setVisible(false);
frame6.setVisible(false);
frame7.setVisible(false);
setVisible(false);
frame2.setVisible(false);
frame3.setVisible(false);
}//end else if
else if(buttonText.equals("Add a new item"))
{
type=2;
String person,place,date;
person=inputLine1.getText();//person
place=inputLine2.getText();//place
date=inputLine3.getText();//date
insert(" ",person,place,date," ",1);
frame1.setVisible(false);
frame2.setVisible(true);
frame3.setVisible(false);
frame4.setVisible(false);
frame5.setVisible(false);
frame6.setVisible(false);
frame7.setVisible(false);
setVisible(false);
}//end else if
break;
case 6:
clickedButton= (JButton) event.getSource();
buttonText=clickedButton.getText();
break;
case 7:
clickedButton= (JButton) event.getSource();
buttonText=clickedButton.getText();
break;
default: break;
}//end switch
//****************************************************************
}//end function actionPerformed
//*************************Program Functions*****************************
public void insert(String mText,String nPerson,String nPlace,String nDate,String nToDoText, int type )
{
Node temp,ptr;
temp=new Node( mText, nPerson, nPlace, nDate, nToDoText,type );
if(root==null)
{//no node exists
root=temp;
}//end if
else
{//at least one node exists
ptr=root;
while((ptr.next)!=null)
{
ptr=ptr.next;
}//end while
ptr.next=temp;
}//end else
}//end insert function
//**************************************************************************
}//end class List
the following is the node class
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author Mustafa Neguib
*/
public class Node {
public int typeOfData;
public String memoText;
public String namePerson;
public String place;
public String date;
public String toDoText;
public Node next;
public Node(String mText,String nPerson,String nPlace,String nDate,String nToDoText,int type )
{
typeOfData=type;
memoText=mText;
namePerson=nPerson;
place=nPlace;
date=nDate;
toDoText=nToDoText;
next=null;
}//end Node constructor
}//end Node class