Reputation: 11
I am getting an error when trying to call the method getuserinput. Here is my bit of the code that is broken.
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"));
}
Upvotes: 0
Views: 762
Reputation: 5291
getuserInput()
is declared as static
. You have to reference it using the class name: NameOfYourClass.getuserInput();
Upvotes: 3