0
getuserinput 메서드를 호출 할 때 오류가 발생합니다. 여기에 깨진 코드가 있습니다.actionlistener가 작동하지 않습니다.
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"));
}
미안하지만 클래스 이름이 무엇인지 확실하지 않습니다. 나는 Main.getusername()을 시도했다. actionPerformed.getuserinput();을 시도했다. ... 조금 더 설명해 줄 수 있었다. – user1183685
@ user1183685 [기본 사항을 재검토] (http://docs.oracle.com) 시간이 걸릴 수있다. /javase/tutorial/java/concepts/class.html). – Jeffrey
이것은'class' 키워드와 붙여 넣기 한 메소드의 어딘가에있는 소스 코드에서'{'기호 다음에 오는 단어입니다. 소스 코드 파일의 이름으로 사용되는 경우가 많습니다. Java 자습서에서 클래스 선언에 대한 자세한 내용 : http://docs.oracle.com/javase/tutorial/java/javaOO/classdecl.html –