Jump to content

Welcome to Geeks to Go - Register now for FREE

Need help with your computer or device? Want to learn new tech skills? You're in the right place!
Geeks to Go is a friendly community of tech experts who can solve any problem you have. Just create a free account and post your question. Our volunteers will reply quickly and guide you through the steps. Don't let tech troubles stop you. Join Geeks to Go now and get the support you need!

How it Works Create Account
Photo

JAVA


  • Please log in to reply

#1
o0MattE0o

o0MattE0o

    Member

  • Member
  • PipPip
  • 29 posts
I have a library system and I have got this piece of code that will display the books into a JTable and when you click on one book it will print it in the console but I need to find out how to link it to my members class and display the book they loan out for each member can some one please :tazz: me

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
  • 0

Advertisements


#2
o0MattE0o

o0MattE0o

    Member

  • Topic Starter
  • Member
  • PipPip
  • 29 posts
no one on here can help then ;)

please :tazz:
  • 0






Similar Topics

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

As Featured On:

Microsoft Yahoo BBC MSN PC Magazine Washington Post HP