JPathList
is a Java Swing component designed to display a list of unique directory and/or file paths. Additionally,
it supports drag-and-drop functionality, allowing users to drag files and directories from their file system into the
list.
JPathList is hosted on the JitPack package repository which supports Gradle, Maven, and sbt.
Add JitPack to your build.gradle
at the end of repositories.
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
Add JPathList as a dependency.
dependencies {
implementation 'com.github.Valkryst:JPathList:2023.11.11-2'
}
Add JitPack as a repository.
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
Add JPathList as a dependency.
<dependency>
<groupId>com.github.Valkryst</groupId>
<artifactId>JPathList</artifactId>
<version>2023.11.11-2</version>
</dependency>
Add JitPack as a resolver.
resolvers += "jitpack" at "https://jitpack.io"
Add JPathList as a dependency.
libraryDependencies += "com.github.Valkryst" % "JPathList" % "2023.11.11-2"
This creates a new JPathList
and displays it in a JFrame
. It is configured to display all files and directories
added to it, so you can immediately test the drag-and-drop functionality.
public class Driver {
public static void main(final String[] args) {
SwingUtilities.invokeLater(() -> {
final var fileList = new JPathList();
fileList.setRecursionMode(JFileChooser.FILES_AND_DIRECTORIES);
final var frame = new JFrame("JPathList Example");
frame.getContentPane().add(new JScrollPane(fileList));
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setPreferredSize(new Dimension(500, 500));
frame.setVisible(true);
frame.pack();
frame.setLocationRelativeTo(null);
});
}
}
The allowed recursion modes are:
JFileChooser.FILES_ONLY
JFileChooser.DIRECTORIES_ONLY
JFileChooser.FILES_AND_DIRECTORIES
Any other values are considered NONE
and will prevent any files or directories from being added to the list.