表模型无法转换为String

时间:2015-02-27 13:38:55

标签: java double tablemodel

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);
                   }
               });
            }
         }
}

我有一个问题是我无法将表模型转换为String。在上面的代码中我想将double转换为字符串,但它有错误。请帮我解决这个问题。

1 个答案:

答案 0 :(得分:1)

喜欢这个吗?

double totalPrice = Double.parseDouble(bookingTable.getModel().getValueAt(row,9).toString());