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?