I am trying to read a textfield. I am using the string=textfield.getText() notion, but all I get a is a blank string back. I am using netbeans and I am using the gui designer within it. I want to hit the "create grid" button and have it create a grid from the integers that the user inputs into the textfield. I have a listener on the button, but I do not know what listener (if any) to put on the the JTextField.
Here is some of the code. Any help would be greatly appreciated.
First the GUI code
//This is the action listener for the button
private void CreateNewGridButtonActionPerformed (java.awt.event.ActionEvent evt)
{
CookieMonster cookie =new CookieMonster();//CookieMonster is my main class
numberOfRows=numberOfRowsField.getText();
numberOfColumns=numberOfColumnsField.getText();
System.out.println(numberOfRows);
}
//this is my best guess of a listener for the JTextfield
private void numberOfRowsFieldActionPerformed(java.awt.event.ActionEvent evt) {
numberOfRows=numberOfRowsField.getText();
}
it will always return an empty string.
Again any help is appreciated. My code in its entirety is attached in files