Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/user-interface/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 使用GUI向arraylist添加对象_Java_User Interface_Arraylist - Fatal编程技术网

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