Lemme first greet all my beloved fellows and i would love to give you all credits for helping each other with problems concerning java!!!

I have a problem with listening methods in my code.the only respond i get is the exit part of my buttons....please i would be happy to get help from you fellows with my actionlistening methods....i was testing with the exit method.

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

 public class Layers // driver function
  {
  
  public static void main(String args[])
          {
          try {UIManager.setLookAndFeel      (UIManager.getSystemLookAndFeelClassName());}
          catch (Exception e) {;}
          Layer_Model model = new Layer_Model();
          Layer_View view = new Layer_View("TRAIN RESERVATION SYSTEM:RESERVATION");
            Layer_Controller controller = new Layer_Controller(model,view);
          }
   }

   class Layer_View extends JFrame//set up GUI
     {
       String reservertions[] = {"Surname","Firstname",
    "ID Number","Email","Phone Number","Place of Departure","No-Of-Tickets",
    "Time of Departure","Time of Arrival"};
      
    private JTextField input = new JTextField(7);
    private JTextField inputName = new JTextField(7);
    private JTextField inputID = new JTextField(7);
               private JTextField inputEmail = new JTextField(7);
    private JTextField inputNumber = new JTextField(7);
    private JTextField inputDeparture = new JTextField(7);
     private JTextField inputDestination = new JTextField(7);
    private JTextField inputTickets = new JTextField(7);
    private JTextField inputDepatime = new JTextField(7);
    private JTextField inputArrival = new JTextField(7);
            
       //declare button components
          JButton price = new JButton("PRICE");
         JButton submit = new JButton("SUBMIT");
         JButton cancel = new JButton("CANCEL");
         JButton exit = new JButton("EXIT");
         JPanel buttons = new JPanel(new GridLayout(4,1,2,2));
        JPanel but = new JPanel(new GridLayout(4,1,2,2));
        
     //BorderLayout pane to hold input/button JPanels
          //border layout to hold inputs and buttons
    JPanel report = new JPanel(new GridLayout(4,1,2,2));
    JPanel main = new JPanel(new BorderLayout());
    
class Layer_Model // provides working functionality
{;}        
        
 public  Layer_View(String title)// constructor method for GUI
  {
    super(title);setBounds(100,100,500,180);setResizable(true);
    setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
    //construct input fieldset
    for (int i=0; i<9;i++)
    {
      JLabel lab = new JLabel(reservertions[i]);
      lab.setForeground(Color.black);
      JPanel p = new JPanel(new FlowLayout(FlowLayout.LEFT));
        
      p.add(lab); switch (i) {
        case 0: p.add(input); break;
        case 1: p.add(inputName); break;
        case 2: p.add(inputID); break;
          case 3: p.add(inputEmail); break;  
          case 4: p.add(inputNumber); break;  
          case 5: p.add(inputDeparture); break;  
          case 6: p.add(inputDestination); break;  
          case 7: p.add(inputTickets); break;  
          case 8: p.add(inputDepatime); break;  
          case 9: p.add(inputArrival); break;       }
          
          report.add(p);
     }
          //constructing buttons
       //construct button controls
       buttons.add(price); but.add(cancel);
       buttons.add(submit); but.add(exit);

      //completing the panel assembly
     main.add("Center",report); main.add("West",buttons); main.add("East",but);



         this.getContentPane().add("Center",main);setVisible(true);
    }
     
     
     
     
class Layer_Controller implements  ActionListener
{
  Layer_Model model; Layer_View view;
  
  public Layer_Controller(Layer_Model model, Layer_View view)
  {
    this.model = model; this.view = view;
    view.buttonActionListeners(this);
     
  }
  
    
 // methods to deal with the interactions performed on the panel.
  public void actionPerformed(ActionEvent ae)
  {
    String action_com = ae.getActionCommand();
    if (action_com.equals("price")) {System.out.print("what price do you want to set");}
    else if (action_com.equals("exit")) {System.exit(0);}
    else if (action_com.equals("submit")) {System.exit(0);}
    else if (action_com.equals("cancel")) {System.exit(0);}
  }

  
 } 

     
    public void buttonActionListeners(ActionListener al)
  {
   price.addActionListener(al);price.setActionCommand("price");
   exit.addActionListener(al);exit.setActionCommand("exit");
   submit.addActionListener(al);submit.setActionCommand("submit");
   cancel.addActionListener(al);cancel.setActionCommand("cancel");
  }
  
}

Please use code tags when you post code.
Reposting it for you here with tags and formatting, but it still will not compile as you have posted it. You mangled the class definitions by embedding them haphazardly in one another.

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

public class Layers // driver function
{
    
    public static void main(String args[]) {
        try {UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());} catch (Exception e) {;}
        Layer_Model model = new Layer_Model();
        Layer_View view = new Layer_View("TRAIN RESERVATION SYSTEM:RESERVATION");
        Layer_Controller controller = new Layer_Controller(model,view);
    }
}

class Layer_View extends JFrame//set up GUI
{
    String reservertions[] = {"Surname","Firstname",
    "ID Number","Email","Phone Number","Place of Departure","No-Of-Tickets",
    "Time of Departure","Time of Arrival"};
    
    private JTextField input = new JTextField(7);
    private JTextField inputName = new JTextField(7);
    private JTextField inputID = new JTextField(7);
    private JTextField inputEmail = new JTextField(7);
    private JTextField inputNumber = new JTextField(7);
    private JTextField inputDeparture = new JTextField(7);
    private JTextField inputDestination = new JTextField(7);
    private JTextField inputTickets = new JTextField(7);
    private JTextField inputDepatime = new JTextField(7);
    private JTextField inputArrival = new JTextField(7);

    //declare button components
    JButton price = new JButton("PRICE");
    JButton submit = new JButton("SUBMIT");
    JButton cancel = new JButton("CANCEL");
    JButton exit = new JButton("EXIT");
    JPanel buttons = new JPanel(new GridLayout(4,1,2,2));
    JPanel but = new JPanel(new GridLayout(4,1,2,2));
    
    //BorderLayout pane to hold input/button JPanels
    //border layout to hold inputs and buttons
    JPanel report = new JPanel(new GridLayout(4,1,2,2));
    JPanel main = new JPanel(new BorderLayout());
    
    class Layer_Model // provides working functionality
    {;}
    
    public Layer_View(String title)// constructor method for GUI
    {
        super(title);setBounds(100,100,500,180);setResizable(true);
        setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
        //construct input fieldset
        for (int i=0; i<9;i++) {
            JLabel lab = new JLabel(reservertions[i]);
            lab.setForeground(Color.black);
            JPanel p = new JPanel(new FlowLayout(FlowLayout.LEFT));
            
            p.add(lab); switch (i) {
                case 0: p.add(input); break;
                case 1: p.add(inputName); break;
                case 2: p.add(inputID); break;
                case 3: p.add(inputEmail); break;
                case 4: p.add(inputNumber); break;
                case 5: p.add(inputDeparture); break;
                case 6: p.add(inputDestination); break;
                case 7: p.add(inputTickets); break;
                case 8: p.add(inputDepatime); break;
                case 9: p.add(inputArrival); break; }
            
            report.add(p);
        }
        //constructing buttons
        //construct button controls
        buttons.add(price); but.add(cancel);
        buttons.add(submit); but.add(exit);
        
        //completing the panel assembly
        main.add("Center",report); main.add("West",buttons); main.add("East",but);
        
        
        
        this.getContentPane().add("Center",main);setVisible(true);
    }
    
    
    
    
    class Layer_Controller implements ActionListener {
        Layer_Model model; Layer_View view;
        
        public Layer_Controller(Layer_Model model, Layer_View view) {
            this.model = model; this.view = view;
            view.buttonActionListeners(this);
            
        }
        
        
        // methods to deal with the interactions performed on the panel.
        public void actionPerformed(ActionEvent ae) {
            String action_com = ae.getActionCommand();
            if (action_com.equals("price")) {System.out.print("what price do you want to set");} else if (action_com.equals("exit")) {System.exit(0);} else if (action_com.equals("submit")) {System.exit(0);} else if (action_com.equals("cancel")) {System.exit(0);}
        }
        
        
    }
    
    
    public void buttonActionListeners(ActionListener al) {
        price.addActionListener(al);price.setActionCommand("price");
        exit.addActionListener(al);exit.setActionCommand("exit");
        submit.addActionListener(al);submit.setActionCommand("submit");
        cancel.addActionListener(al);cancel.setActionCommand("cancel");
    }
    
}
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.