I made code in the first page which consists 4 buttons , each button has program

If you select any button the program will run on, but there isn't syntax error

but there re some buttons not executed because I use JOptionPane and I don't know where is the problem and why not execute?

Recommended Answers

All 3 Replies

How are we supposed to help if you do not provide any code?
Secondly is this problem sorted or still on going? If sorted you should clearly state so ...

i tried to enter the attach the code but it's invalid

first program 
import java.io.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
import java.util.*;

class AddressBook implements ActionListener
    {
    	 
          JPanel topPanel,bottomPanel;
    	  JScrollPane scrollPane;
    	  JFrame frame;
    	 
    	  JMenuBar menubar = new JMenuBar(); ;
       	  JMenu menu = new JMenu();
       	  JMenuItem menuItem;
       	  
       	  Toolkit kit = Toolkit.getDefaultToolkit();
       	  Dimension screenSize = kit.getScreenSize();
       	  int screenHeight = screenSize.height;
       	  int screenWidth = screenSize.width;
       	  
       	  Image img = kit.getImage("images/icon.JPG");
   	 
    	  AddressBook()
    	    {
    	   	 
            	    frame = new JFrame("Address Book");
            	    frame.setSize(680,200);
                    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                    frame.setLocation(screenWidth/4, screenHeight/4);
                    frame.setIconImage(img);
                    addWidgets();
                    frame.show();
           
            }
                                    
                                    
    	  
         public void addWidgets()
         
            {
            	   	menubar.add(menu);
       	            
       	            menu = new JMenu("Options");
       	            menuItem = new JMenuItem("Add New Contact");
       	            menu.add(menuItem);
       	            menuItem.addActionListener(this);
       	            
       	            menuItem = new JMenuItem("Delete Contact");
       	            menu.add(menuItem);
       	            menuItem.addActionListener(this);
       	            
       	            menuItem = new JMenuItem("Search Contacts");
       	            menu.add(menuItem);
       	            menuItem.addActionListener(this);
       	            
       	            menuItem = new JMenuItem("Sort Contacts");
       	            menu.add(menuItem);
       	            menuItem.addActionListener(this);
       	            
       	            menuItem = new JMenuItem("View All Contacts");
       	            menu.add(menuItem);
       	            menuItem.addActionListener(this);  
       	            
       	            menuItem = new JMenuItem("Backup Contacts");
       	            menu.add(menuItem);
       	            menuItem.addActionListener(this);	            
       	            

       	            menubar.add(menu);
       	            
       	            menu = new JMenu("Help");
       	            
       	            menuItem = new JMenuItem("Help Contents");
       	            menu.add(menuItem);
       	            menuItem.addActionListener(this);
       	            
       	            menuItem = new JMenuItem("About");
       	            menu.add(menuItem);
       	            menuItem.addActionListener(this);
       	            
       	            menubar.add(menu);
       	            
       	            frame.setJMenuBar(menubar);
       	            
       	            
       	            JPanel topPanel = new JPanel();            
                    JPanel bottomPanel = new JPanel();
                    
                    //Add Buttons To Bottom Panel
                    JButton AddNew = new JButton("Add New Contact");
                    JButton DeleteContact = new JButton("Delete Contact");     
                    JButton SearchContacts = new JButton("Search Contacts");               
                    JButton SortContacts = new JButton("Sort Contacts");
                    JButton ViewContactList = new JButton("View All Contacts");
                    
                    JLabel label = new JLabel("<HTML><FONT FACE = ARIAL SIZE = 2><B>Use The options below and In The Menu To Manage Contacts");
                    
                    //Add Action Listeners
                    AddNew.addActionListener(this);
                    DeleteContact.addActionListener(this);
                    SearchContacts.addActionListener(this);                    
                    SortContacts.addActionListener(this);
                    ViewContactList.addActionListener(this);        
                    
                    topPanel.add(label);
                      
                    bottomPanel.add(AddNew);
                    bottomPanel.add(DeleteContact);
                    bottomPanel.add(SearchContacts);                                        
                    bottomPanel.add(SortContacts);
                    bottomPanel.add(ViewContactList);

                    frame.getContentPane().add(topPanel, BorderLayout.NORTH);
                    frame.getContentPane().add(bottomPanel, BorderLayout.SOUTH);
                    frame.setResizable(false);
            	
            	
            	
            }
         
         
         public static void main(String args[])
            {
            	AddressBook add = new AddressBook();
            	
            }
            
         
    	 OperationHandler oh = new OperationHandler();
    	 
    	 public void actionPerformed(ActionEvent ae)
    	    {
    	        if(ae.getActionCommand() == "Add New Contact")
    	            { 
    	                 oh.AddNew();
    	            
    	            }
    	            
    	        else  if(ae.getActionCommand() == "Search Contacts")
    	            { 
    	                 oh.SearchContacts();
    	            
    	            }    
    	            
    	        else  if(ae.getActionCommand() == "Sort Contacts")
    	            { 
    	                 oh.SortContacts();
    	            
    	            }     	            
    	        
    	        else  if(ae.getActionCommand() == "Delete Contact")
    	            { 
    	                  oh.DeleteContact();
    	            
    	            }    
    	            
    	        else  if(ae.getActionCommand() == "View All Contacts")
    	            { 
    	                  
    	                  oh.ViewAllContacts();
    	            
    	            }       
    	         
    	        else  if(ae.getActionCommand() == "About")
    	            { 
    	                  JOptionPane.showMessageDialog(frame, "About Address Book:\n\nCreated By ....","About Address Book", JOptionPane.INFORMATION_MESSAGE);
    	                 
    	            }
    	        else  if(ae.getActionCommand() == "Help Contents")
    	            { 
    	                try
    	                 {  
    	                     oh.showHelp();
    	                 }
    	                catch(IOException e)
    	                 {
    	                 } 
    	            
    	            }
    	         else  if(ae.getActionCommand() == "Backup Contacts")
    	            { 
    	                JFileChooser chooser = new JFileChooser();
    	     	        chooser.setCurrentDirectory(new File("."));
    	     	        chooser.setMultiSelectionEnabled(false);
    	     	        chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
    	     	        chooser.showSaveDialog(frame);
    	     	        FileOutputStream  bfout = null;
    	     	        FileInputStream bfin = null;
    	     	        String filename=null;
    	     	        
    	     	        int p;
    	     	        
    	     	        try
    	     	         { 
    	     	             filename = chooser.getSelectedFile().getPath();
    	     	         }
    	     	        catch(Exception e)
    	     	         {
    	     	         } 
    	     	             	        
    	     	        try
    	     	           {  	
    	     	              bfout = new FileOutputStream(filename + "\\data.dat");
    	     	           }
    	     	        catch(Exception e)
    	     	           {
    	     	           	
    	     	           }   
    	     	        try
    	     	          {
    	     	             bfin = new FileInputStream("data/data.dat");
    	     	          }
    	     	        catch(Exception e)
    	     	          {
    	     	          
    	     	          }
    	     	        
    	     	        try
    	     	           {
    	     	           	   do
    	     	           	     {  p = bfin.read();
    	     	           	        if(p!=-1)
    	     	           	            bfout.write(p);
    	     	           	     }while(p!=-1);
    	     	           	}
    	     	         catch(Exception e)
    	     	            {
    	     	            
    	     	            }  	

    	                    	                
    	            }       
    	                          
    	    }   
     
    
    }
    

class Contact implements Serializable
    {
    	 private String FName;
    	 private String LName;
    	 private String Nname;
    	 private String EMail;
    	 private String Address;
    	 private String PhoneNo;
    	 private String Webpage;
    	 private String Bday;   
    	 
    	 public void setDetails(String fname, String lname, String nname, String email, String address, String phone, String web, String bday)
    	     {
    	     	  FName = fname;
    	     	  LName = lname;
    	     	  Nname = nname;
    	     	  EMail = email;
    	     	  Address = address;
    	     	  PhoneNo = phone;
    	     	  Webpage = web;
    	     	  Bday = bday;
             }
             
                       
         public String getFName()
             {
             	  return FName;
             }     
          
         public String getLName()
             {
             	  return LName;
             }     

         public String getNname()
             {
             	  return Nname;
             }     

          public String getEMail()
             {
             	  return EMail;
             }     

          public String getAddress()
             {
             	  return Address;
             }     
             
          public String getPhoneNo()
             {
             	  return PhoneNo;
             }     

          public String getWebpage()
             {
             	  return Webpage;
             }     

          public String getBday()
             {
             	  return Bday;
             }     

                
    }
    	      
    
class OperationHandler implements ListSelectionListener, ActionListener, Runnable
    {
       

       JFrame newFrame;
       JTextField txtFirstName;
       JTextField txtLastName; 
       JTextField txtNickname;
       JTextField txtEMail;
       JTextField txtAddress;
       JTextField txtPhoneNo;
       JTextField txtWebpage;
       JTextField txtBDay;
       
       JButton BttnSaveAdded;
       
       Vector v = new Vector(10,3);
       int i=0,k=0;
       
       Toolkit kit = Toolkit.getDefaultToolkit();
       Dimension screenSize = kit.getScreenSize();
       int screenHeight = screenSize.height;
       int screenWidth = screenSize.width;
       
       Image img = kit.getImage("images/icon.JPG");
       
       FileInputStream fis;
       ObjectInputStream ois;
       
       JList list;
       DefaultListModel listModel;
       ListSelectionModel listSelectionModel;
       
       JRadioButton byfname, bylname;
       
       Thread t;
       
       JTable searchTable;
       
       JTextField txtSearch;
       
       String columnNames[] = { "First Name", 
                                                  "Last Name", 
                                                  "Nickname", 
                                                  "E Mail Address", 
                                                  "Address", 
                                                  "Phone No.", 
                                                  "Webpage", 
                                                  "B'day" 
                                                };
                                                
       Object data[][]= new Object[5][8];   
       
       OperationHandler()
           {
           
                try {
                       fis = new FileInputStream("data/data.dat");
                       ois = new ObjectInputStream(fis);
                       v = (Vector) ois.readObject();
                       ois.close();
                    }

               catch(Exception e)
                    {
                    	
                    }      

           }       

    	
    	public void run()
    	   {
    	   	   
    	   	   try
           	    {             	                  
           	         FileOutputStream fos = new FileOutputStream("data/data.dat");
           	         ObjectOutputStream oos = new ObjectOutputStream(fos);
                     oos.writeObject(v);
           	         oos.flush();
           	         oos.close();
           	                  
           	    }
           	   catch(Exception e)
           	    {
           	    	  JOptionPane.showMessageDialog(newFrame, "Error Opening Data File: Could Not Save Contents.", "Error Opening Data File", JOptionPane.INFORMATION_MESSAGE);
           	    }       
    	   	
    	   }

       
       public void AddNew()
           {
               newFrame = new JFrame("Add New");
               newFrame.setSize(220,250);
               newFrame.setResizable(false);
               newFrame.setIconImage(img);
               
               JLabel lblFirstName = new JLabel("First Name: ");
               JLabel lblLastName = new JLabel("Last Name: ");
               JLabel lblNickname = new JLabel("Nickname: ");
               JLabel lblEMail = new JLabel("EMail: ");  
               JLabel lblAddress = new JLabel("Address: ");
               JLabel lblPhoneNo = new JLabel("Phone No: ");
               JLabel lblWebpage = new JLabel("Webpage: ");
               JLabel lblBDay = new JLabel("BDay: ");
               JLabel lblEmpty1 = new JLabel("");
               JLabel lblEmpty2 = new JLabel(""); 
                              
               txtFirstName = new JTextField(10);
               txtLastName = new JTextField(10);
               txtNickname = new JTextField(10);
               txtEMail = new JTextField(10);
               txtAddress = new JTextField(10);
               txtPhoneNo = new JTextField(10);
               txtWebpage = new JTextField(10);
               txtBDay = new JTextField(10);
               
               JButton BttnAdd = new JButton("Add New!");
               BttnSaveAdded = new JButton("Save Added!");
               
               BttnAdd.addActionListener(this);
               BttnSaveAdded.addActionListener(this);
               BttnSaveAdded.setEnabled(false);
                             
               
               JPanel centerPane = new JPanel();
               JPanel bottomPane = new JPanel();
               
               centerPane.add(lblFirstName);               
               centerPane.add(txtFirstName);
               centerPane.add(lblLastName);
               centerPane.add(txtLastName);
               centerPane.add(lblNickname);
               centerPane.add(txtNickname);
               centerPane.add(lblEMail);
               centerPane.add(txtEMail);
               centerPane.add(lblAddress);
               centerPane.add(txtAddress);
               centerPane.add(lblPhoneNo);
               centerPane.add(txtPhoneNo);
               centerPane.add(lblWebpage);
               centerPane.add(txtWebpage);
               centerPane.add(lblBDay);
               centerPane.add(txtBDay);
               bottomPane.add(BttnAdd);
               bottomPane.add(BttnSaveAdded);
               
               centerPane.setLayout(new GridLayout(0,2));
               
               
               newFrame.getContentPane().add(centerPane,BorderLayout.CENTER);
               newFrame.getContentPane().add(bottomPane,BorderLayout.SOUTH);
               newFrame.setLocation(screenWidth/4, screenHeight/4);
               newFrame.show();
           
           }
      

       public void SearchContacts()
           {
           	   newFrame = new JFrame("Search Contacts");
               newFrame.setSize(700,220);
               newFrame.setLocation(screenWidth/4, screenHeight/4);
               newFrame.setIconImage(img);
               newFrame.setResizable(false);
               
               JPanel topPane = new JPanel();
               JLabel label1 = new JLabel("Search Contacts by First Name or Last Name or Both Spaced Via a Single Space:");
               topPane.add(label1);
               
               JPanel centerPane = new JPanel();
               JLabel label2 = new JLabel("Search String:");
               txtSearch = new JTextField(20);
               JButton bttnSearch = new JButton("Search!");
               bttnSearch.addActionListener(this);
               JButton bttnCancel = new JButton("Cancel");
               bttnCancel.addActionListener(this);               
               centerPane.add(label2);
               centerPane.add(txtSearch);
               centerPane.add(bttnSearch);
               centerPane.add(bttnCancel);
                 
               searchTable = new JTable(data,columnNames);
               JScrollPane scrollPane = new JScrollPane(searchTable);
               searchTable.setPreferredScrollableViewportSize(new Dimension(500, 90));                                    	
               newFrame.getContentPane().add(scrollPane,BorderLayout.SOUTH);

               newFrame.getContentPane().add(topPane, BorderLayout.NORTH);              
               newFrame.getContentPane().add(centerPane, BorderLayout.CENTER);
               newFrame.show();          	 
           }
 
 
       public void SortContacts()
           {
               newFrame = new JFrame("Sort Contacts");
               newFrame.setSize(250,160);
               newFrame.setLocation(screenWidth/4, screenHeight/4);
               newFrame.setIconImage(img);
               newFrame.setResizable(false);
               
               byfname = new JRadioButton("By First Name");
               byfname.setActionCommand("By First Name");
               byfname.setSelected(true);
               
               bylname = new JRadioButton("By Last Name");
               bylname.setActionCommand("By Last Name");
                             
			ButtonGroup group = new ButtonGroup();
               group.add(byfname);
               group.add(bylname);
               
               JPanel topPane = new JPanel();
               JLabel label = new JLabel("Sort Contacts By:");
               topPane.add(label);
                              
               JPanel pane = new JPanel(new GridLayout(0,1));
               pane.add(byfname);
               pane.add(bylname);
               
               JPanel bottomPane = new JPanel();
               JButton sortBttn = new JButton("Sort Contacts");
               JButton cancelBttn = new JButton("Cancel");
               bottomPane.add(sortBttn);
               bottomPane.add(cancelBttn);
               sortBttn.addActionListener(this);
               cancelBttn.addActionListener(this);
                              
               newFrame.getContentPane().add(topPane, BorderLayout.NORTH);                              
               newFrame.getContentPane().add(pane, BorderLayout.CENTER);
               newFrame.getContentPane().add(bottomPane, BorderLayout.SOUTH);
               
               newFrame.show();
               
           }
      
      
       public void DeleteContact()
           {
               String fname, lname;
               newFrame = new JFrame("Delete Contact");
               newFrame.setSize(300,300);
               newFrame.setLocation(screenWidth/4, screenHeight/4);
               newFrame.setIconImage(img);
               
               JPanel centerPane = new JPanel();
               listModel = new DefaultListModel();
               
               Contact contact = new Contact();
               
               for(int l=0;l<v.size();l++)
                     {
                     	contact = (Contact) v.elementAt(l);
                     	
                     	fname = contact.getFName();
                     	lname = contact.getLName();
                     	listModel.addElement(fname + " " + lname);
                     	               	
                     }
               
  
               list = new JList(listModel);
               list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
               listSelectionModel = list.getSelectionModel();
               listSelectionModel.addListSelectionListener(this);
               
               JScrollPane listScrollPane = new JScrollPane(list);
          
               JPanel topPane = new JPanel();
               JLabel label = new JLabel("Current Contacts:");
               topPane.add(label);
               
               JPanel bottomPane = new JPanel();               	
               
               JButton bttnDelete = new JButton("Delete Selected");
               bottomPane.add(bttnDelete);
               bttnDelete.addActionListener(this);
               
               JButton bttnCancel = new JButton("Cancel");
               bottomPane.add(bttnCancel);
               bttnCancel.addActionListener(this);
               
               newFrame.getContentPane().add(topPane, BorderLayout.NORTH);
               newFrame.getContentPane().add(listScrollPane, BorderLayout.CENTER);
               newFrame.getContentPane().add(bottomPane, BorderLayout.SOUTH);
               
               newFrame.show();
           
           }
       
    
       public void ViewAllContacts()
           {
           	        
           	        newFrame = new JFrame("All Contacts In The Address Book");
                    newFrame.setSize(600,300);
                    newFrame.setIconImage(img);
                    
                    Contact con = new Contact();
                   
                               	        
           	        String columnNames[] = { "First Name", 
                                          "Last Name", 
                                          "Nickname", 
                                          "E Mail Address", 
                                          "Address", 
                                          "Phone No.", 
                                          "Webpage", 
                                          "B'day" 
                                         };
                                 
                                 
                              
                    Object data[][]= new Object[v.size()][8];
                                 
                                         
                    for(int j=0;j<v.size();j++)
                            {    
                                                    
                                 con = (Contact) v.elementAt(k);
                                 
                                 data[j][0] = con.getFName();
                                 data[j][1] = con.getLName();
                                 data[j][2] = con.getNname();
                                 data[j][3] = con.getEMail();
                                 data[j][4] = con.getAddress();
                                 data[j][5] = con.getPhoneNo();
                                 data[j][6] = con.getWebpage();
                                 data[j][7] = con.getBday();
                                 
                                 k++;
                                 
                            }
                     k=0;       
                
                     JTable abtable = new JTable(data,columnNames);
                     JScrollPane scrollPane = new JScrollPane(abtable);
                     abtable.setPreferredScrollableViewportSize(new Dimension(500, 370));
                     
                     JPanel pane = new JPanel();
                     JLabel label = new JLabel("Contacts Currently In The Address Book");
                     pane.add(label);
                     
                     newFrame.getContentPane().add(pane,BorderLayout.SOUTH);
                     newFrame.getContentPane().add(scrollPane, BorderLayout.CENTER);
                     newFrame.setLocation(screenWidth/4, screenHeight/4);
                     newFrame.show();
                     
                     
                     
                     
           }
           
       public void showHelp() throws IOException
           {
                
                String title = "Help Contents";
                String data = "";
                FileInputStream fishelp = null;
                int i;
                
                newFrame = new JFrame(title);
                newFrame.setSize(401, 400);
                newFrame.setResizable(false);
                newFrame.setLocation(screenWidth/4, screenHeight/4);
                newFrame.setIconImage(img);
                
                JTextArea textArea = new JTextArea(5,20);
                textArea.setLineWrap(true);
                textArea.setEditable(false);
                
                try
                  {
                  	  fishelp= new FileInputStream("help/help.txt");
                  }
                catch(Exception e)
                  {
                  	  JOptionPane.showMessageDialog(newFrame, "Help File Not Found.", "Help File Not Found", JOptionPane.INFORMATION_MESSAGE);
                  }  
                    
                do
                 {
                 	 i = fishelp.read();
                 	 if(i!=1) 
                 	     data = data + (char) i;
                 } while(i!=-1);
                
                fishelp.close(); 	     
                 	    
                textArea.setText(data);
                
                JPanel bottomPane = new JPanel();
                JButton button = new JButton("Ok");
                bottomPane.add(button);
                button.addActionListener(this);
                
                JPanel topPane = new JPanel();
                JLabel label = new JLabel(title);
                topPane.add(label);
                                
                JScrollPane scrollPane = new JScrollPane(textArea);
                
                newFrame.getContentPane().add(topPane,BorderLayout.NORTH);
                newFrame.getContentPane().add(scrollPane);
                newFrame.getContentPane().add(bottomPane,BorderLayout.SOUTH);
                
                newFrame.show();
                
           
           }    

        
       public void actionPerformed(ActionEvent ae)
           {  
              
           	   
           	  if(ae.getActionCommand() == "Add New!")
           	       {
           	            
           	            if(txtFirstName.getText().equals("") && txtLastName.getText().equals("") && txtNickname.getText().equals("") && txtEMail.getText().equals("") && txtAddress.getText().equals("") && txtPhoneNo.getText().equals("") && txtWebpage.getText().equals("") && txtBDay.getText().equals(""))
           	                { 
           	                     JOptionPane.showMessageDialog(newFrame, "Entries Empty! Fill in the required entries to save Contact.", "Entries Empty", JOptionPane.INFORMATION_MESSAGE);
           	                     
           	                  }
           	                 
           	            else
           	               {   	
           	                   Contact contact = new Contact();
           	                   contact.setDetails(txtFirstName.getText(),txtLastName.getText(),txtNickname.getText(),txtEMail.getText(),txtAddress.getText(),txtPhoneNo.getText(),txtWebpage.getText(),txtBDay.getText());
           	                   v.addElement(contact);
           	                   txtFirstName.setText("");
           	                   txtLastName.setText("");
           	                   txtNickname.setText("");
           	                   txtEMail.setText("");
           	                   txtAddress.setText("");
           	                   txtPhoneNo.setText("");
           	                   txtWebpage.setText("");
           	                   txtBDay.setText("");
           	                   
           	                   if(BttnSaveAdded.isEnabled() == false)
           	                        BttnSaveAdded.setEnabled(true);
           	              }
           	              
 
           	           
           	       }
           	   else if(ae.getActionCommand() == "Save Added!")
           	       {
           	       	
           	       	 saveVector();
           	       	 newFrame.setVisible(false);
           	       
           	       	   
           	       }
           	    else if(ae.getActionCommand() == "Ok")
           	       {
           	            newFrame.setVisible(false);             	            
           	          
           	       }
           	    else if(ae.getActionCommand() == "Delete Selected")
           	       {
           	            
           	            int index;
           	            try
           	              {              

           	                 index = list.getSelectedIndex();
           	                            	                 
           	                 if(index==-1)
           	                   {
                                    JOptionPane.showMessageDialog(newFrame, "Select a Contact first to delete it.", "Select a Contact First", JOptionPane.INFORMATION_MESSAGE);
                               }
                               
                             else
                              {
                              	
                              	    int n = JOptionPane.showConfirmDialog(newFrame, "Are you sure you want to delete the selected Contact?", "Are you sure?", JOptionPane.YES_NO_OPTION);

           	                 
                                    if (n == JOptionPane.YES_OPTION) 
                                        {
                                  	         listModel.remove(index);
                                         	 v.removeElementAt(index);
           	                                 saveVector();
           	                                 newFrame.show();
           	                                 
                                         
                                        } 
                                     else if (n == JOptionPane.NO_OPTION) 
                                        {
                                     
                                        }
           	                 
           	                  }       	            
           	               
           	               }
           	             catch(Exception e)
           	               {
           	               	  
           	               }    
           	          
           	       }   
           	    else if(ae.getActionCommand() == "Cancel")
           	       {
           	            
           	            newFrame.setVisible(false);
           	       }
           	    else if(ae.getActionCommand() == "Search!")
           	       {
           	            String SearchStr;
           	            SearchStr = txtSearch.getText();
           	            boolean flag=false;
           	            Contact con = new Contact();
           	            int c=0;
           	            
           	            for(int t=0;t<5;t++)
           	               {
           	               	   data[t][0] = "";
           	                   data[t][1] = "";
           	                   data[t][2] = "";
           	                   data[t][3] = "";
           	                   data[t][4] = "";
           	                   data[t][5] = "";
           	                   data[t][6] = "";
           	                   data[t][7] = "";
           	               }
           	               
                        for(int t=0;t<v.size();t++)
                            {    
                                                    
                                 con = (Contact) v.elementAt(t);
                                 
                                 if(SearchStr.equalsIgnoreCase(con.getFName()) || SearchStr.equalsIgnoreCase(con.getLName()) || SearchStr.equalsIgnoreCase(con.getFName() + " " + con.getLName()))
                                    {
                                    	flag=true;
                                 
                                        data[c][0] = con.getFName();
                                        data[c][1] = con.getLName();
                                        data[c][2] = con.getNname();
                                        data[c][3] = con.getEMail();
                                        data[c][4] = con.getAddress();
                                        data[c][5] = con.getPhoneNo();
                                        data[c][6] = con.getWebpage();
                                        data[c][7] = con.getBday();
                                        searchTable = new JTable(data,columnNames);
                                        newFrame.setSize(700,221);
                                        newFrame.setSize(700,220);                                      
                                        
                                        if(c<5)
                                             c++;
                                    }  
                                 
                            }
                         

           	             if(flag)
           	                {
           	                   JOptionPane.showMessageDialog(newFrame, "Contact Found!", "Search Result!", JOptionPane.INFORMATION_MESSAGE);
           	                }
           	                
           	             else
           	                {
           	                   JOptionPane.showMessageDialog(newFrame, "No Such Contact Found!", "Search Result!", JOptionPane.INFORMATION_MESSAGE);
           	                }
 
           	                  
           	       }
           	    else if(ae.getActionCommand() == "Sort Contacts")
           	       {
           	            
                     if(byfname.isSelected())
                       {   
                           Contact contact1 = new Contact();
                           Contact contact2 = new Contact();
                           Contact temp = new Contact();
                           int l,m;
               
                           for(l=0;l<v.size()-1;l++)
                             {
                               for(m=l+1;m<v.size();m++)
                                 {
                                 	contact1 = (Contact) v.elementAt(l);
                                  	contact2 = (Contact) v.elementAt(m);
                     	
                                 	if(contact1.getFName().compareTo(contact2.getFName()) > 0)
                                 	    {
                     	                   temp = (Contact) v.elementAt(m);
                     	                   v.setElementAt(v.elementAt(l),m);
                     	                   v.setElementAt(temp,l);
                     	                }

                                 }
                              }
                
                           saveVector();    	            
           	            }
           	          else
           	            {
           	            	
                           Contact contact1 = new Contact();
                           Contact contact2 = new Contact();
                           Contact temp = new Contact();
                           int l,m;
               
                           for(l=0;l<v.size()-1;l++)
                             {
                               for(m=l+1;m<v.size();m++)
                                 {
                                 	contact1 = (Contact) v.elementAt(l);
                                  	contact2 = (Contact) v.elementAt(m);
                     	
                                 	if(contact1.getLName().compareTo(contact2.getLName()) > 0)
                                 	    {
                     	                   temp = (Contact) v.elementAt(m);
                     	                   v.setElementAt(v.elementAt(l),m);
                     	                   v.setElementAt(temp,l);
                     	                }

                                 }
                              }
                
                           saveVector();            	            	
           	            }
           	      
           	          newFrame.setVisible(false);
           	      }    
           	      
           
           }
           
       
       public void saveVector()
           {
           	      t = new Thread(this, "Save Vector Thread");
    	          t.start();
           	
           }  
       
       
       public void valueChanged(ListSelectionEvent lse)
           {

           	   
           }    

    }
second program

import java.io.*;
import java.util.*;
import java.lang.*;
import javax.swing.*;
import java.awt.*;

public class pGeneralSorting1{

    public static void BubbleSort(Comparable[] a){
        boolean switched = true;
        for(int i=0;i<a.length-1 && switched;i++){
            switched = false;
            for(int j=0;j<a.length-i-1;j++)
                if(a[j].compareTo(a[j+1]) > 0){
                    switched = true;
                    Comparable hold = a[j];
                    a[j] = a[j+1];
                    a[j+1] = hold;
                }
        }
    }

    public static void SelectionSort(Comparable[] a){
        for(int i = a.length-1;i>0;i--){
            Comparable large = a[0];
            int indx = 0;
            for(int j = 1;j <= i;j++)
                if(a[j].compareTo(large) > 0){
                    large = a[j];
                    indx = j;
                }
            a[indx] = a[i];
            a[i] = large;
        }
    }

    public static void InsertionSort(Comparable[] a){
        int i,j;
        Comparable e;
        for(i=1;i<a.length;i++){
            e = a[i];
            for(j=i-1;j>=0 && a[j].compareTo(e) > 0;j--)
                a[j+1] = a[j];
            a[j+1] = e;
        }
    }

    public static void HeapSort(Comparable[] a){
        int i,f,s;
        for(i=1;i<a.length;i++){
            Comparable e = a[i];
            s = i;
            f = (s-1)/2;
            while(s > 0 && a[f].compareTo(e) < 0){
                a[s] = a[f];
                s = f;
                f = (s-1)/2;
            }
            a[s] = e;
        }
        for(i=a.length-1;i>0;i--){
            Comparable value = a[i];
            a[i] = a[0];
            f = 0;
            if(i == 1)
                s = -1;
            else
                s = 1;
            if(i > 2 && a[2].compareTo(a[1]) > 0)
                s = 2;
            while(s >= 0 && value.compareTo(a[s]) < 0){
                a[f] = a[s];
                f = s;
                s = 2*f+1;
                if(s+1 <= i-1 && a[s].compareTo(a[s+1]) < 0)
                    s = s+1;
                if(s > i-1)
                    s = -1;
            }
            a[f] = value;
        }
    }

   

    public static void main(String[] args){
        Integer[] a = new Integer[10];
        
        for(int i=0;i<a.length;i++){
          a[i]=Integer.parseInt( JOptionPane.showInputDialog(null,"Please Enter the array!!"));
			  //JOptionPane.showMessageDialog(null," " + a[i]);
        }
        BubbleSort(a);
        HeapSort(a);
         InsertionSort(a);
         SelectionSort(a);
        JFrame frame = new JFrame("Display");
	frame.getContentPane();
        frame.setLayout(new FlowLayout());
	JTextArea area=new JTextArea();
	area.setSize(100,100);
        frame.add(area);
        JTextArea area2=new JTextArea();
	area2.setSize(100,100);
        frame.add(area2);
        JTextArea area3=new JTextArea();
	area3.setSize(100,100);
        frame.add(area3);
        JTextArea area4=new JTextArea();
	area4.setSize(100,100);
        frame.add(area4);
	frame.setSize(500,200);
	frame.setLocation(0,0);
	for(int i=0;i<a.length;i++)
	{
            String str = " "+ a[i++];
	area.append("HEAPSorting"+str+"\n");
        area2.append("SelectionSorting"+str+"\n");
        area3.append("QuikSorting"+str+"\n");
        area4.append("insertionSorting"+str+"\n");}
        frame.setVisible(true);
        
     
    }
}
thired program

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

class stack
{
    public int arr[],ac;
    stack()
    {
	arr=new int[100];
	ac=0;
    }
    stack(int num)
    {
	arr=new int[num];
	ac=0;
    }
    void push(int key)
    {
	if(ac==arr.length)return;
	arr[ac++]=key;
	return;
    }
    int pop()
    {
	if(ac==0)return -1;
	return arr[--ac];
    }
    int instack(int key)
    {
	for(int i=0;i<ac;i++)
	{
	    if(arr[i]==key)return 1;
	}
	return 0;
    }
    boolean isempty()
    {
	return ac==0;
    }
}

class queue
{
    public int arr[],front,rear,count;
    queue()
    {
	arr=new int[100];
	front=0;
	rear=0;
	count=0;
    }
    queue(int num)
    {
	arr=new int[num];
	front=0;
	rear=0;
	count=0;
    }
    void insert(int key)
    {
	if(rear==arr.length)return;
	arr[rear++]=key;
	count++;
    }
    int get()
    {
	if(front==rear)return -1;
	count--;
	return arr[front++];
    }
    int inqueue(int key)
    {
	for(int i=front;i<rear;i++)
	{
	    if(arr[i]==key)
		return 1;
	}
	return 0;
    }
    boolean isempty()
    {
	return count==0;
    }
}

class edge
{
    int v1,v2,wt;
    edge(int u,int v,int w)
    {
	v1=u;
	v2=v;
	wt=w;
    }
    edge()
    {
	v1=0;
	v2=0;
	wt=0;
    }
}

class vertex
{
    int adj[],ac;
    int wt[];    
    boolean visit;
    vertex()
    {
	adj=new int[100];
	ac=0;
	wt=new int[100];
	visit=false;
    }
    void addedge(int v,int w)
    {
	adj[ac++]=v;
	wt[ac-1]=w;
	return;
    }
    void display(int num)
    {
	JOptionPane.showMessageDialog(null,num);
    }
    void flag()
    {
	visit=true;
    }
    void clear()
    {
	visit=false;
    }
    int isadj(int v)
    {
	for(int i=0;i<ac;i++)
	{
	    if(adj[i]==v)return wt[i];
	}
	return 0;
    }
}

class graph
{
    vertex vert[];
    edge edges[];
    int vc,ec;
    int set[][],sc[],num; /*For Kruskal*/
    graph(int vt)
    {
	vert=new vertex[vt];
	vc=vt;
	for(int i=0;i<vc;i++)
	    vert[i]=new vertex();
	edges=new edge[100];
	ec=0;
	/*For Kruskal*/
	set=new int[vc][vc];
	sc=new int[100];
	num=0;
	/*End of Kruskal initialization*/
    }
    int Kfind(int a)/*For Kruskal*/
    {
	for(int i=0;i<num;i++)
	{
	    for(int j=0;j<sc[i];j++)
	    {
		if(set[i][j]==a)return i;
	    }
	}
	return -1;
    }
    void Kmerge(int a,int b)/*For Kruskal*/
    {
	for(int i=0;i<sc[b];i++)
	{
	    set[a][sc[a]+i]=set[b][i];
	}
	sc[a]+=sc[b];
	for(int i=b+1;i<num;i++)
	{
	    for(int j=0;j<sc[i];j++)
	    {
		set[i-1][j]=set[i][j];
	    }
	    sc[i-1]=sc[i];
	}
	num--;
	return;
    }
    int getedgelength(int u,int v)
    {
	if(u==v)return 0;
	for(int i=0;i<ec;i++)
	{
	    if(edges[i].v1==u && edges[i].v2==v)
		return edges[i].wt;
	    else if(edges[i].v2==u && edges[i].v1==v)
		return edges[i].wt;
	}
	return 9999;
    }
    void sortedges()
    {
	for(int i=0;i<ec;i++)
	{
	    for(int j=i+1;j<ec;j++)
	    {
		if(edges[i].wt>edges[j].wt)
		{
		    edge temp;
		    temp=edges[i];
		    edges[i]=edges[j];
		    edges[j]=temp;
		}
	    }
	}
	return;
    }
    graph Kruskal()/*Kruskal main function*/
    {
	for(int i=0;i<vc;i++)
	{
	    set[i][0]=i;
	    sc[i]=1;
	}
	num=vc;
	sortedges();
	graph g=new graph(vc);
	for(int i=0;i<ec;i++)
	{
	    int a=Kfind(edges[i].v1);
	    int b=Kfind(edges[i].v2);
	    if(a!=b)
	    {
		g.addedges(edges[i].v1,edges[i].v2,edges[i].wt);
		Kmerge(a,b);
		if(g.getedgecount()>=(vc-1))break;
	    }	    
	}
	return g;
    }		
    boolean present(int[] a,int ac,int b)/*if b is present in a[0] thru a[ac-1]*/
    {
	for(int i=0;i<ac;i++)
	{
	    if(a[i]==b)return true;
	}
	return false;
    }
    int Dijkistra(int u,int v)/*Returs shortest length between u and v*/
    {
	int label[]=new int[vc];	
	int found[]=new int[vc];
	int ver[]=new int[vc];
	int fc=1;
	found[0]=u;
	for(int i=0;i<vc;i++)
	{
	    label[i]=getedgelength(u,i);
	    ver[i]=i;
	}
	while(fc<vc)
	{
	    for(int i=0;i<vc;i++)
	    {
		for(int j=i+1;j<vc;j++)
		{
		    if(label[i]>label[j])
		    {
			int temp=label[i];
			label[i]=label[j];
			label[j]=temp;
			temp=ver[i];
			ver[i]=ver[j];
			ver[j]=temp;
		    }
		}
	    }
	    int i;
	    for(i=0;present(found,fc,ver[i]);i++);
	    found[fc++]=ver[i];
	    int vs=i;
	    for(i=0;i<vc;i++)
	    {
		if(label[i]>(label[vs]+getedgelength(found[fc-1],ver[i])))
		    label[i]=label[vs]+getedgelength(found[fc-1],ver[i]);
	    }
	}
	for(int i=0;i<vc;i++)
	{
	    if(ver[i]==v)return label[i];
	}
	return 9999;
    }
    void dft(int v)/*DFT main*/
    {
	clearvisit();
	stack st=new stack(100);
	int c=v;
	int count;
	while(true)
	{
	    vert[c].flag();
	    vert[c].display(c);
	    count=0;
	    for(int i=0;i<vert[c].ac;i++)
	    {
		if(vert[vert[c].adj[i]].visit==false)
		    count++;
	    }
	    if(count==0 && st.isempty())
		break;
	    else if(count==0)
	    {
		c=st.pop();
	    }
	    else
	    {
		int y=-1;
		for(int i=0;i<vert[c].ac;i++)
		{
		    if(vert[vert[c].adj[i]].visit==false && y==-1)
			y=vert[c].adj[i];
		    else if(vert[vert[c].adj[i]].visit==false)
		    {
			st.push(vert[c].adj[i]);
			vert[vert[c].adj[i]].flag();
		    }
		}
		c=y;
	    }
	}
    }
    void bft(int v)/*BFT main*/
    {
	clearvisit();
	queue q=new queue(100);
	int c=v;
	int count;
	while(true)
	{
	    vert[c].flag();
	    vert[c].display(c);
	    for(int i=0;i<vert[c].ac;i++)
	    {
		if(vert[vert[c].adj[i]].visit==false)
		{
		    q.insert(vert[c].adj[i]);
		    vert[vert[c].adj[i]].flag();
		}
	    }
	    if(q.isempty())
		break;
	    c=q.get();
	}
    }
    void addedges(int u,int v,int wt)
    {
	edges[ec++]=new edge(u,v,wt);
	vert[u].addedge(v,wt);
	vert[v].addedge(u,wt);
    }
    int getedgecount()
    {
	return ec;
    }
    void clearvisit()
    {
	for(int i=0;i<vc;i++)
	    vert[i].clear();
    }
    void displayedges()
    {
        JFrame frame = new JFrame("Display");
        JLabel person = new JLabel (new ImageIcon("headerimage_services.jpg"));
        person.setSize(500,200);
	frame.getContentPane();
        frame.setLayout(new BorderLayout());
	JTextArea area=new JTextArea();
	area.setSize(200,100);
	frame.add(person,BorderLayout.NORTH);
        frame.add(area,BorderLayout.CENTER);
	frame.setSize(660,300);
	frame.setLocation(0,0);
	for(int i=0;i<ec;i++)
	{
      String str =  "Edge "+i+" between "+edges[i].v1+" & "+edges[i].v2+" of wt:"+edges[i].wt;	
	area.append(str+"\n");}
        frame.setVisible(true);
        

	}
    
    int isadj(int u,int v)
    {
	return vert[u].isadj(v);
    }	    
}

class graphs
{
    public static void main(String args[])throws IOException
    {
	int ch;
	//DataInputStream in=new DataInputStream(System.in);
      //System.out.println("Graphs 1.04\nDeepak\n<deepak-p@eth.net");
      //System.out.println("Release Date: 28-June-2002");
      //System.out.println("http://www.geocities.com/acmesofties/");
	ch=Integer.parseInt(JOptionPane.showInputDialog(null,"Enter number of vertices:"));
	//ch=Integer.parseInt(in.readLine());
	 graph gr=new graph(ch);
	ch=1;
	while(ch!=20)
	{
	   ch=Integer.parseInt(JOptionPane.showInputDialog(null,"\n1.Add Edge\n2.Display\n3.DFT\n4.BFT\n5.tree of the graph MST\n6.shortest length  SL\n10.Exit"));
	    //ch=Integer.parseInt(in.readLine());
	    switch(ch)
	    {
		case 1:
		{
                    int s = gr.vc;
                    int d = s-1;
                JOptionPane.showMessageDialog(null,"Vertices are numbered 1 thru'"+ d);
		    int i=Integer.parseInt(JOptionPane.showInputDialog(null,"Enter 1st vertex:"));
		   // int i=Integer.parseInt(in.readLine());
		    int j=Integer.parseInt( JOptionPane.showInputDialog(null,"Enter 2nd vertex:"));
                     int y=Integer.parseInt( JOptionPane.showInputDialog(null,"Enter weight between the vertex:"));
		    gr.addedges(i,j,y);
		    JOptionPane.showMessageDialog(null,"Added Edge");
		    break;
		}
		case 2:
		{
		    JOptionPane.showMessageDialog(null,"Vertices:"+gr.vc);
		    gr.displayedges();
		    break;
		}
		case 3:
		{
		     int j=Integer.parseInt(JOptionPane.showInputDialog(null,"Enter vertex for search to begin:"));
		    //int j=Integer.parseInt(in.readLine());
		    gr.dft(j);
		    break;
		}
		case 4:
		{
		   int j=Integer.parseInt(JOptionPane.showInputDialog(null,"Enter vertex to begin search:"));
		    //int j=Integer.parseInt(in.readLine());
		    gr.bft(j);
		    break;
		}
		case 5:
		{
		    JOptionPane.showMessageDialog(null,"Processing MST...");
		    graph g=gr.Kruskal();
		    JOptionPane.showMessageDialog(null,"Vertices:"+g.vc);
		    g.displayedges();
		    break;
		}
		case 6:
		{
		    int i=Integer.parseInt(JOptionPane.showInputDialog(null,"Enter starting vertex:"));
		   // int i=Integer.parseInt(in.readLine());
                   int j=Integer.parseInt(JOptionPane.showInputDialog(null,"Enter ending vertex:"));
		   // int j=Integer.parseInt(in.readLine());
		    int path=gr.Dijkistra(i,j);
		   JOptionPane.showMessageDialog(null,"Shortest path length:"+path);
		    break;
		}
		default:
		    ch=20;
	    }
	}
    }
}
fourth program

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

public class Towers extends JFrame{


public static void TowersOfHanoi(String source, String dest, 
 String temp, int n)
 
{
  
if(n > 0)
{
TowersOfHanoi(source, temp, dest, n-1);
        JFrame frame = new JFrame("Display");
	frame.getContentPane();
        frame.setSize(300,100);
        frame.setLayout(new BorderLayout());
	JTextArea area=new JTextArea();
	area.setSize(300,100);
        frame.add(area,BorderLayout.SOUTH);
         String str=null;
        for(int i=0;i<n;i++)
	{
        str= " " + source+" -> "+dest;}
	area.append(str);
        frame.setVisible(true);
TowersOfHanoi(temp, dest, source, n-1);
}
}

public static void main(String[] args)
        {

                int n;
                // Prompt the user
                
            

                        // Read a line of text from the user.
                        String input = JOptionPane.showInputDialog(null,"Type a positive integer." );

                        // converts a String into an int value
                        n = Integer.parseInt( input );

                
                        String source = JOptionPane.showInputDialog(null,"Type the name of the source peg:");
                
                        String dest = JOptionPane.showInputDialog(null,"Type the name of the destination peg:");

                        String temp = JOptionPane.showInputDialog(null,"Type the name of the temporary peg:");

                         TowersOfHanoi(source, dest, temp, n);

                
               



        } // end of main

} // end of class
the fifth program

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

public class Towers extends JFrame{


public static void TowersOfHanoi(String source, String dest, 
 String temp, int n)
 
{
  
if(n > 0)
{
TowersOfHanoi(source, temp, dest, n-1);
        JFrame frame = new JFrame("Display");
	frame.getContentPane();
        frame.setSize(300,100);
        frame.setLayout(new BorderLayout());
	JTextArea area=new JTextArea();
	area.setSize(300,100);
        frame.add(area,BorderLayout.SOUTH);
         String str=null;
        for(int i=0;i<n;i++)
	{
        str= " " + source+" -> "+dest;}
	area.append(str);
        frame.setVisible(true);
TowersOfHanoi(temp, dest, source, n-1);
}
}

public static void main(String[] args)
        {

                int n;
                // Prompt the user
                
            

                        // Read a line of text from the user.
                        String input = JOptionPane.showInputDialog(null,"Type a positive integer." );

                        // converts a String into an int value
                        n = Integer.parseInt( input );

                
                        String source = JOptionPane.showInputDialog(null,"Type the name of the source peg:");
                
                        String dest = JOptionPane.showInputDialog(null,"Type the name of the destination peg:");

                        String temp = JOptionPane.showInputDialog(null,"Type the name of the temporary peg:");

                         TowersOfHanoi(source, dest, temp, n);

                
               



        } // end of main

} // end of class

//////////// the last one i was grouping by button

public class mainTnter extends javax.swing.JFrame {
    
    /** Creates new form mainTnter */
    public mainTnter() {
        initComponents();
    }
    
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
    private void initComponents() {
        jLabel1 = new javax.swing.JLabel();
        jButton1 = new javax.swing.JButton();
        jButton2 = new javax.swing.JButton();
        jButton3 = new javax.swing.JButton();
        jButton4 = new javax.swing.JButton();
        jButton5 = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        jLabel1.setIcon(new javax.swing.ImageIcon("C:\\Documents and Settings\\Admin\\Desktop\\datasturcture Project\\projectFinal\\headerimage_services.jpg"));

        jButton1.setText("Sorting");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                Sorting_app(evt);
            }
        });

        jButton2.setText("Graph(DFT/BFT/SP)");
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                gra_dbs(evt);
            }
        });

        jButton3.setText("Draw/Del Graph");
        jButton3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                Draw_app(evt);
            }
        });

        jButton4.setText("Stack (holowil tower)");
        jButton4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                Stack_app(evt);
            }
        });

        jButton5.setText("AddressBook");
        jButton5.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                address_app(evt);
            }
        });

        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jLabel1)
            .add(layout.createSequentialGroup()
                .add(55, 55, 55)
                .add(jButton1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 133, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .add(105, 105, 105)
                .add(jButton2)
                .add(110, 110, 110)
                .add(jButton3, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 130, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
            .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
                .addContainerGap(171, Short.MAX_VALUE)
                .add(jButton5, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 135, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .add(119, 119, 119)
                .add(jButton4)
                .add(142, 142, 142))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(layout.createSequentialGroup()
                .add(jLabel1)
                .add(26, 26, 26)
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(jButton1)
                    .add(jButton3)
                    .add(jButton2))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 45, Short.MAX_VALUE)
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(jButton5)
                    .add(jButton4))
                .add(21, 21, 21))
        );
        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void gra_dbs(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_gra_dbs
graphs gr = new graphs();
    }//GEN-LAST:event_gra_dbs

    private void address_app(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_address_app
AddressBook ad = new AddressBook();
    }//GEN-LAST:event_address_app

    private void Draw_app(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_Draw_app
BasicTreeAddDelete drde = new BasicTreeAddDelete();
    }//GEN-LAST:event_Draw_app

    private void Stack_app(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_Stack_app
Towers sta = new Towers();
    }//GEN-LAST:event_Stack_app

    private void Sorting_app(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_Sorting_app
pGeneralSorting1 sor = new pGeneralSorting1();
    }//GEN-LAST:event_Sorting_app
    
    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new mainTnter().setVisible(true);
            }
        });
    }
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JButton jButton3;
    private javax.swing.JButton jButton4;
    private javax.swing.JButton jButton5;
    private javax.swing.JLabel jLabel1;
    // End of variables declaration//GEN-END:variables
    
}

I don't see any attempt at debugging in that code (No print statements at the beginning of method calls for tracing, no .printStackTrace in your catches, etc).

Run the code with debugging calls and tell us what happens.

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.