I’m new to java. I create project where I have one textField and one button. I make function for button, where I start my other function and it’s ok. But I need to take number value from textField as parameter for my function…
b1.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e)
{
int price;
int quantity = Integer.parseInt(tf2.getText());
int totalamount = price*quantity;
//need to insert this total amout into textfield tf4 //
tf4.getText(totalamount); //showing error ;
}
});
help me in please ,thank you in advance
This is simple…
You can get integer value from textfield like
getText() method are use to get value from textfield and If this value is integer the you can parse it like Integer.parseInt, If this value is string then you can get this value using toString() method.
and you can set this value like
setText() method are use to set text to Textfield.
You can use this value in function call as a parameter to call function like
And use this value in Function Definition like
You have to read Basic Java. Here is link which help you