编码中预期的错误标识符

时间:2015-02-27 09:18:41

标签: identifier

我的代码一直在说标识符,我真的不知道为什么,有什么建议吗?

import java.awt.*;

  import java.awt.event.*;

  import javax.swing.*;

  import javax.swing.border.*;

  import java.awt.BorderLayout;

  import javax.swing.JFrame;

  import javax.swing.JButton;

  import javax.swing.JLabel;

  import java.awt.event.ActionListener;

  import java.awt.event.ActionEvent;




public class BorderLayoutJFrame extends JFrame implements ActionListener

{

    public static final int WIDTH = 400;
    public static final int HEIGHT = 400;

    public BorderLayoutJFrame()
    {
     super ("BorderLayoutDemo"); 
      setSize (WIDTH, HEIGHT);
      setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

        JLabel displayPanel = new JLabel ("UP");//adds the display panel

        JButton[] buttons = {new JButton("UP"), new JButton("RIGHT"),
                     new JButton("DOWN"), new JButton("LEFT")};

        JLabel label = new JLabel("Center");
        add(label, BorderLayout.CENTER);




        displayPanel.setHorizontalAlignment(SwingConstants.LEFT); // sets the horizontal alignment CENTER, LEFT, RIGHT

        displayPanel.setVerticalAlignment(SwingConstants.TOP); // sets the vertical alignment CENTER, TOP, BOTTOM

      add(buttons[0], BorderLayout.NORTH);
      add(buttons[1], BorderLayout.EAST);
      add(buttons[2], BorderLayout.SOUTH);
      add(buttons[3], BorderLayout.WEST);

    }
        button1.addActionListener
        (
        public void actionPerformed(ActionEvent e)
                   {
                       system.out.println("Going Up!");
                    }

        button2.addActionListener;
        (
        public void actionPerformed(ActionEvent e)
                   {
                       system.out.println("Going Right!");
                    }

        button3.addActionListener;
        (
        public void actionPerformed(ActionEvent e)
                   {
                       system.out.println("Going Down!");
                    }

        button4.addActionListener;
        (
        public void actionPerformed(ActionEvent e)
                   {
                       system.out.println("Going Left!");
                    }
    }

0 个答案:

没有答案