private void display() { data = new Vector(); books = library.getBook().getBook(); for (int i =0; i<books.size(); i++) { Book libraryBooks = (Book) books.get(i); Vector row = new Vector(); row.add(libraryBooks.getISBN()); row.add(libraryBooks.getPublisher()); row.add(libraryBooks.getAuthor()); row.add(libraryBooks.getTitle()); row.add(new Double(libraryBooks.getAmount())); data.add(row); System.out.println("Testing Library Book Storage"+"\n"+libraryBooks); } model = new DefaultTableModel(data, columns); bookTable.setModel(model); } void bookTable_mouseClicked(MouseEvent e) { //String isbn=null; //String publisher=null; //String author=null; //String title=null; //Double amount=null; //going to change to int int row = bookTable.getSelectedRow(); TableColumnModel colModel = bookTable.getColumnModel(); String isbn = (String)bookTable.getValueAt(row, 0); String publisher = (String)bookTable.getValueAt(row, 1); String author = (String)bookTable.getValueAt(row, 2); String title = (String)bookTable.getValueAt(row, 3); Double amount = (Double)bookTable.getValueAt(row, 4); //going to change to int /* //////////////////////////////////////////////// for(int col=0;col<colModel.getColumnCount();col++){ Object value = bookTable.getValueAt(row, col); if(col==0){ isbn = (String)value; } else if(col==1){ publisher = (String)value; } else if(col==2){ author = (String)value; } else if(col==3){ title = (String)value; } else if(col==4){ amount = (Double)value; //going to change to int } } //////////////////////////////////////////////// */ System.out.println("ISBN: " + isbn + ", Publisher: " + publisher + ", Author: " + author + ", Title: " + title + " , Amount: " + amount); } }
I can send the whole program I have so far if it helps