Code that works on Windows Laptops but not on Mac for some reason

六月ゝ 毕业季﹏ 提交于 2019-12-24 20:55:36

问题


import java.awt.*;
                    // Contains the Classes for Controls

public class increment extends EasyApp          // EasyApp provides simplified commands
{                                             //  for creating controls and making
   public static void main(String[] args)     //  the actions method simpler
   {   new increment();   }

   //-------- creating CONTROLS -----------------------------------
   List nums = addList("2|4|6",160,200,50,40,this);
   TextField number     = addTextField("",50,200,100,40,this);

   public increment()                                  // Constructor
   {                                                 //  This runs at the beginning.
       setTitle("My First GUI App");                  //  You can do things like 
       setSize(400,300);                              //  changing the Window size
       number.setFont(new Font("Arial",0,20) );    //  or appearance of Controls.
   }

   public void actions(Object source,String command) // When a Button is clicked,
   {                                                 //  this method decides how
       if (nums.getSelectedItem().equals("2")){
           double num = Double.parseDouble(number.getText()) +2;
           number.setText(num + "");
       }
       if (nums.getSelectedItem().equals("4")){
           double num = Double.parseDouble(number.getText()) +4;
           number.setText(num + "");
       }
       if (nums.getSelectedItem().equals("6")){
           double num = Double.parseDouble(number.getText()) +6;
           number.setText(num + "");
       }
   }
}

The above code is intended to create a dropdown menu (that contains numbers 2,4 and 6) next to a textbox. The user types a number into the textbox and then clicks an option on the dropdown menu into the textbox. The program is then supposed to add the number chosen on the dropdown menu to the number in the textbox. For some reason, the code works in Windows computer but not on Mac's. Can anyone please help?

来源:https://stackoverflow.com/questions/55044678/code-that-works-on-windows-laptops-but-not-on-mac-for-some-reason

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!