java - 表模型无法转换为字符串

标签 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 转换为字符串,但它出现了错误。请帮我解决这个问题。

最佳答案

像这样吗?

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

关于java - 表模型无法转换为字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28766448/

相关文章:

java - JTable中添加Image时显示的字符串路径

java - 从java中的其他类访问私有(private)变量

Java 将 64 位整数解释为 float

python2.7 将二进制有符号 double 转换为 ASCII 的难度

c++ - 如何将字符串(包含双最大值)转换为 double

java - 模型更新时 JTable 不更新

java - 如何使用自定义 TableModel 删除 JTable 中的行

java - 从 spring 重定向 url 中删除项目名称前缀

java - 如何解决eclipse中的java.lang.ClassNotFoundException

Java线程启动时间