asiavoices
Programmer
Hello again everyone,
I was wondering what would be the best way of retrieving info entered on a form via a JTextField and JCheckBox(boolean) and passing them as an argument to a method I've created.
I believe I am close but I cannot get by the boolean (i.e JCheckbox) error message (at least that's where I think the error originates):
Error Message during compilation:
MyProgram.java [349:1] cannot resolve symbol
symbol : method booleanValue ()
location: class javax.swing.JCheckBox
Boolean theTaxState = new Boolean(isTaxField.booleanValue());
MyProgram.java [351:1] addItem (java.lang.String,double,boolean) in MyProgram cannot be applied to
(java.lang.String,double,java.lang.Boolean)
addItem(theName, thePrice, theTaxState);
/* ================================ */
Here's my code snippet:
JTextField descriptionField = new JTextField(15);
JTextField priceField = new JTextField(8);
JCheckBox isTaxField = new JCheckBox("Yes", true);
......
public void actionPerformed(ActionEvent theClickedEvent)
{
......
String theName = new String(descriptionField.getText());
double thePrice = new Double(priceField.getText()).doubleValue();
Boolean theTaxState = new Boolean(isTaxField.booleanValue());
/* ---- my method ------------->
addItem(theName, thePrice, theTaxState);
.......
} // end of actionPerformed
/* -------- addItem method() ----------- */
public void addItem(String name, double thePrice, boolean taxState)
{
ArrayList myStuff = new ArrayList();
Item cidx = new Item(name, thePrice, taxState);
myStuff.add(cidx);
numrecords++;
showList(myStuff);
......
}
Any help is greatly appreciated....
Cheers,
Christopher
I was wondering what would be the best way of retrieving info entered on a form via a JTextField and JCheckBox(boolean) and passing them as an argument to a method I've created.
I believe I am close but I cannot get by the boolean (i.e JCheckbox) error message (at least that's where I think the error originates):
Error Message during compilation:
MyProgram.java [349:1] cannot resolve symbol
symbol : method booleanValue ()
location: class javax.swing.JCheckBox
Boolean theTaxState = new Boolean(isTaxField.booleanValue());
MyProgram.java [351:1] addItem (java.lang.String,double,boolean) in MyProgram cannot be applied to
(java.lang.String,double,java.lang.Boolean)
addItem(theName, thePrice, theTaxState);
/* ================================ */
Here's my code snippet:
JTextField descriptionField = new JTextField(15);
JTextField priceField = new JTextField(8);
JCheckBox isTaxField = new JCheckBox("Yes", true);
......
public void actionPerformed(ActionEvent theClickedEvent)
{
......
String theName = new String(descriptionField.getText());
double thePrice = new Double(priceField.getText()).doubleValue();
Boolean theTaxState = new Boolean(isTaxField.booleanValue());
/* ---- my method ------------->
addItem(theName, thePrice, theTaxState);
.......
} // end of actionPerformed
/* -------- addItem method() ----------- */
public void addItem(String name, double thePrice, boolean taxState)
{
ArrayList myStuff = new ArrayList();
Item cidx = new Item(name, thePrice, taxState);
myStuff.add(cidx);
numrecords++;
showList(myStuff);
......
}
Any help is greatly appreciated....
Cheers,
Christopher