ActionListener не работает - PullRequest
       0

ActionListener не работает

0 голосов
/ 16 февраля 2012

Я получаю сообщение об ошибке при попытке вызвать метод getuserinput. Вот мой бит кода, который не работает.

initialvelocitybutton.addActionListener(new ActionListener() { 
            public void actionPerformed(ActionEvent e) {
        getuserinput(); //I am getting an error saying "The method getuserinput() is undefined for the type new ActionListener(){}"
           }
        });

static void getuserinput(){   //method to get users input
                double initialvelocity = Double.parseDouble(
                           JOptionPane.showInputDialog("please enter initial velocity")); //gets initial value of intiial velcoity
                double angleoflaunch = Double.parseDouble(
                           JOptionPane.showInputDialog("please enter angle of launch"));
}

1 Ответ

3 голосов
/ 16 февраля 2012

getuserInput() объявлено как static. Вы должны ссылаться на него, используя имя класса: NameOfYourClass.getuserInput();

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...