I'm trying to compare two variables that is being inputed by the user but then it wont function
if (txt_pay.getItem() < txt_amount.getItem())
{
jOptionPane1.showMessageDialog(this, "please enter the right amount");
}
what could be wrong?
the error says
operator < cannot be applied to java.lang.string
another one is when there is no value it will say please input a number.
if (txt_pay.getItem().isEmpty())
{
jOptionPane1.showMessageDialog(this, "please enter the right amount");
}
or
if (txt_pay.getItem() = NULL)
{
jOptionPane1.showMessageDialog(this, "please enter the right amount");
}
i'm trying those code to put it in here but unluckily it wont function.
if (txt_pay.getText()!= "")
{
double iChange = Double.valueOf(txt_pay.getText()) - Double.valueOf(txt_amount.getText());
txt_change.setText(String.valueOf(iChange));
jOptionPane1.showMessageDialog(this, "Your Change will be given to you with your order!. Thank you for using our system");
this.hide();
}
String[] tableColumnsName = {"ID","Item","Price","Qty"};
DefaultTableModel aModel = (DefaultTableModel) jTable1.getModel();
aModel.setColumnIdentifiers(tableColumnsName);
ResultSet rs =globals.executeQry("select id,item,price,qty from tblorders where cabin='" +
globals.cabin + "' and seatnum1='" + globals.seatnum1 + "' and seatnum2='" + globals.seatnum2 + "'");
try
{
// Loop through the ResultSet and transfer in the Model
java.sql.ResultSetMetaData rsmd = rs.getMetaData();
int colNo = rsmd.getColumnCount();
while(rs.next()){
Object[] objects = new Object[colNo];
// tanks to umit ozkan for the bug fix!
for(int i=0;i<colNo;i++){
objects[i]=rs.getObject(i+1);
}
aModel.addRow(objects);
}
jTable1.setModel(aModel);
NumberFormat formatter = NumberFormat.getCurrencyInstance();
formatter.setMaximumFractionDigits(2);
//Double iTotal=0.00;
for (int i=0;i<=(jTable1.getRowCount()-1);i++)
{
globals.executesqlcom("update tblinventory set itemcount= itemcount -" + jTable1.getValueAt(i, 3).toString() +
" where itemname='" + jTable1.getValueAt(i, 1).toString() + "'");
}
}
catch(Exception ex)
{
ex.printStackTrace();
}
hope someone could help me... thanks in advance!