有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

在Windows笔记本电脑上工作但由于某些原因不能在Mac上工作的java代码

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 + ""); } } }

上述代码用于在文本框旁边创建一个下拉菜单(包含数字2、4和6)。用户在文本框中键入一个数字,然后在文本框中单击下拉菜单上的一个选项。然后,程序将在下拉菜单上选择的数字添加到文本框中的数字。由于某些原因,该代码在Windows计算机上工作,但在Mac上不工作。有人能帮忙吗


共 (0) 个答案