Table 模型无法转换为字符串
Table model cannot converted to String
private void createNewMemberCheckInRecord(){
int row = bookingTable.getSelectedRow();
if(row<0){
JOptionPane.showMessageDialog(null, "Please choose a booking","ERROR",JOptionPane.ERROR_MESSAGE);
}
else{
final String roomType = ((BookingTableModel)bookingTable.getModel()).getValueAt(row,3).toString();
=============================================================
final double totalPrice = (Double.parseDouble((BookingTableModel)bookingTable.getModel()).getValueAt(row,9).toString());
=============================================================
final String memberName = ((BookingTableModel)bookingTable.getModel()).getValueAt(row,7).toString();
final String receptionistName = ((BookingTableModel)bookingTable.getModel()).getValueAt(row,8).toString();
final String appStatus = ((BookingTableModel)bookingTable.getModel()).getValueAt(row,5).toString();
final String appID = ((BookingTableModel)bookingTable.getModel()).getValueAt(row,0).toString();
if(appStatus.equals("CheckOut") || appStatus.equals("Cancel")){
JOptionPane.showMessageDialog(null, "The booking either CheckOut or canceled","ERROR",JOptionPane.ERROR_MESSAGE);
}
else {
SwingUtilities.invokeLater(new Runnable(){
@Override
public void run() {
CheckInRecordServiceJFrame checkInRecordServiceJFrame = new CheckInRecordServiceJFrame(getPanel(),roomType,memberName,receptionistName,totalPrice,appID);
}
});
}
}
}
我有一个问题是我无法将 table 模型转换为字符串。在上面的代码中,我想将双精度转换为字符串,但是 errors.Please 帮我解决了这个问题。
像这样?
double totalPrice = Double.parseDouble(bookingTable.getModel().getValueAt(row,9).toString());
private void createNewMemberCheckInRecord(){
int row = bookingTable.getSelectedRow();
if(row<0){
JOptionPane.showMessageDialog(null, "Please choose a booking","ERROR",JOptionPane.ERROR_MESSAGE);
}
else{
final String roomType = ((BookingTableModel)bookingTable.getModel()).getValueAt(row,3).toString();
=============================================================
final double totalPrice = (Double.parseDouble((BookingTableModel)bookingTable.getModel()).getValueAt(row,9).toString());
=============================================================
final String memberName = ((BookingTableModel)bookingTable.getModel()).getValueAt(row,7).toString();
final String receptionistName = ((BookingTableModel)bookingTable.getModel()).getValueAt(row,8).toString();
final String appStatus = ((BookingTableModel)bookingTable.getModel()).getValueAt(row,5).toString();
final String appID = ((BookingTableModel)bookingTable.getModel()).getValueAt(row,0).toString();
if(appStatus.equals("CheckOut") || appStatus.equals("Cancel")){
JOptionPane.showMessageDialog(null, "The booking either CheckOut or canceled","ERROR",JOptionPane.ERROR_MESSAGE);
}
else {
SwingUtilities.invokeLater(new Runnable(){
@Override
public void run() {
CheckInRecordServiceJFrame checkInRecordServiceJFrame = new CheckInRecordServiceJFrame(getPanel(),roomType,memberName,receptionistName,totalPrice,appID);
}
});
}
}
}
我有一个问题是我无法将 table 模型转换为字符串。在上面的代码中,我想将双精度转换为字符串,但是 errors.Please 帮我解决了这个问题。
像这样?
double totalPrice = Double.parseDouble(bookingTable.getModel().getValueAt(row,9).toString());