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

Recommended Answers

All 7 Replies

hi all, this is my first time using JAVA. i know other programming languages, such as, c++, PHP, Assembly.

This is your first time using Java and you're writing a 1500 line program? What happened to starting with "Hello World"? It's an awful lot of code to work through, so you'll probably have to pinpoint us to the correct line/function. The 100% CPU suggests an infinite loop of some kind. The fact that you don't get an out of memory error may just mean something else crashed it first. it may well be a memory leak, but it's probably a memory leak based on an infinite loop. Find the infinite loop and there's a decent chance you'll find the problem, memory or otherwise.

Since this is a GUI program that crashes whenever you press a button, it's time to look in the actionPerformed code for the buttons that crash it and pinpoint where it's happening. Netbeans' debugger is pretty good. Stick lots of breakpoints in, see where you're infinite looping (I'm assuming that's it). Comment stuff out, comment it back in, see how far you get, etc.

thanx for answering, ya its a big program for a first time. however i believe it is the to make the logic that is most important while the language is just a tool. if i can program in c++ then why can i not program in JAVA they are quite similar to me.

i also think there is a memory, leak. ill look for the infinite function and see what else i can find and will post back here with the update.

When you say "crashes", what exactly happens - do you get an Exception thrown, does it just stop responding, does it disappear, does NetBeans stop responding or disappear, (etc)? Does it crash when you press the exit" button?
If it's really an insufficient memory problem you should see a different result if you run it outside netbeans, or if you increase the VM memory size, but I don't see anything obvious in your code that looks like a memory hog. Given the 100% CPU symptom I too would start by suspecting any potential infinite loops.

When you say "crashes", what exactly happens - do you get an Exception thrown, does it just stop responding, does it disappear, does NetBeans stop responding or disappear, (etc)? Does it crash when you press the exit" button?
If it's really an insufficient memory problem you should see a different result if you run it outside netbeans, or if you increase the VM memory size, but I don't see anything obvious in your code that looks like a memory hog. Given the 100% CPU symptom I too would start by suspecting any potential infinite loops.

thanx for the reply.

when i insert data in the linked list, and then press any button or menu item that is on the gui of the program, the program becomes unresponsive. i have to close the program from the task manager. netbeans becomes unresponsive during that time. when the program is closed net beans get the control back.

i tried running the program on a basic sdk which can be found from the sun website and the same problem occurs. i tried the program on eclipse as well but i get the same problem.

i am going to rethink the logic for the program, and see if the problem goes away.

You can close the program WITHIN NEtBeans usually. Look at the lower right part of your screen and see if there is something that has "(run)" as part of its text there when a program is running. There should be an "x" you can click to stop the program. That's if NetBeans isn't crashing. It didn't crash when I ran your program. Your program became unresponsive, but NetBeans didn't, so I clicked the "x".

I put the following debugging statements in your constructor at the beginning and end, respectively.

System.out.println ("Entering constructor " + type);

and

System.out.println ("Exiting constructor " + type);

The result was that when type was 3, under certain conditions, it would enter and not exit, so that may narrow things down for you. I question the whole program design though. I'd say you have not nearly enough classes. It's all one big List class. List is a confusing name for a class that extends JFrame. I try to keep my GUI classes and other classes separate as much as possible. List should refer to a LinkedList or something similar, not a JFrame, in my opinion.

I think you did extremely well to get a program this long to compile on your first attempt at Java. Still, it's a bit big to manage for your first time, I think. Like any other language, there's a lot of ins and outs to get used to, and till you do, it'll probably be better to tackle something smaller.

thanx guys, i am designing the program again. as vernondozier said ill be now keeping the gui in seperate classes and my data input and storing in some other classes and tie them together.

tux4life thanx for the link and will check it out.
when im done with the program ill give an update.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.