Java 使用GUI向arraylist添加对象
这是程序的相关块Java 使用GUI向arraylist添加对象,java,user-interface,arraylist,Java,User Interface,Arraylist,这是程序的相关块 public void actionPerformed(ActionEvent event) { String command = event.getActionCommand(); if(command.equals("Add Book")) { addBook(); } if(command.equals("Clear")) { cl
public void actionPerformed(ActionEvent event)
{
String command = event.getActionCommand();
if(command.equals("Add Book"))
{
addBook();
}
if(command.equals("Clear"))
{
clear();
}
}
/**
* Add a Book to the arraylist LoanItem
*/
public void addBook(String theISBN, String theTitle, String thePublisher)
{
Book theBook = new Book(theISBN, theTitle, thePublisher);
LoanItems.add(theBook);
出现错误时,类库中的addbook方法无法应用于给定类型。
有帮助吗?您调用了addBook()
,但没有传递为其指定的任何参数。您需要获取您应该传递的信息,然后将其提供给呼叫:
if ("clear".equalsIgnoreCase(command)) {
addBook(String, String, String);
}