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 –