OpenFilesEvent (Java SE 25 & JDK 25)
Description: declaration: module: java.desktop, package: java.awt.desktop, class: OpenFilesEvent
Keywords: java.awt.desktop.OpenFilesEvent class

# Class OpenFilesEvent

java.lang.Object
java.util.EventObject
java.awt.desktop.AppEvent
java.awt.desktop.FilesEvent
java.awt.desktop.OpenFilesEvent

All Implemented Interfaces:
  `Serializable`

public final class OpenFilesEvent extends FilesEvent
Event sent when the app is asked to open a list of files.

Since:
  9
See Also:
  - `OpenFilesHandler.openFiles(OpenFilesEvent)`
  - Serialized Form

- ## Field Summary

  ### Fields declared in class EventObject

  `source`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `OpenFilesEvent(List<File> files, String searchTerm)`
  Constructs an `OpenFilesEvent`.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `String`
  `getSearchTerm()`
  Gets the search term.

  ### Methods declared in class FilesEvent

  `getFiles`

  ### Methods declared in class EventObject

  `getSource, toString`

  ### Methods declared in class Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- ## Constructor Details

  - ### OpenFilesEvent

    public OpenFilesEvent(List<File> files, String searchTerm)
    Constructs an `OpenFilesEvent`.
    Parameters:
      `files` - the list of files
      `searchTerm` - the search term
    Throws:
      `HeadlessException` - if `GraphicsEnvironment.isHeadless()` returns `true`
      `UnsupportedOperationException` - if Desktop API is not supported on the current platform
    See Also:
      - `Desktop.isDesktopSupported()`
      - `GraphicsEnvironment.isHeadless()`

- ## Method Details

  - ### getSearchTerm

    public String getSearchTerm()
    Gets the search term. The platform may optionally provide the search term that was used to find the files. This is for example the case on MacOS, when the files were opened using the Spotlight search menu or a Finder search window.

    This is useful for highlighting the search term in the documents when they are opened.

    Returns:
      the search term used to find the files