簡體   English   中英

動作監聽器不起作用

[英]actionlistener not working

嘗試調用方法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"));
}

getuserInput()被聲明為static 您必須使用類名稱引用它: NameOfYourClass.getuserInput();

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM