https://github.com/valkryst/jtoggleablepasswordfield
JToggleablePasswordField is a Java Swing component that extends the standard JPasswordField with the ability to toggle between showing and hiding the password.
https://github.com/valkryst/jtoggleablepasswordfield
hacktoverfest java-gui jpasswordfield jtextfield swing swing-component
Last synced: 4 months ago
JSON representation
JToggleablePasswordField is a Java Swing component that extends the standard JPasswordField with the ability to toggle between showing and hiding the password.
- Host: GitHub
- URL: https://github.com/valkryst/jtoggleablepasswordfield
- Owner: Valkryst
- License: apache-2.0
- Created: 2025-03-01T20:23:44.000Z (4 months ago)
- Default Branch: master
- Last Pushed: 2025-03-01T20:43:29.000Z (4 months ago)
- Last Synced: 2025-03-01T21:26:12.484Z (4 months ago)
- Topics: hacktoverfest, java-gui, jpasswordfield, jtextfield, swing, swing-component
- Language: Java
- Homepage:
- Size: 9.77 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE.md
Awesome Lists containing this project
README
`JToggleablePasswordField` is a Java Swing component that extends the standard `JPasswordField` with the ability to toggle
between showing and hiding the password. It features a clickable visibility icon that allows users to temporarily reveal
their password to verify its correctness.Requires Java 11.
## Table of Contents
* [Installation](https://github.com/Valkryst/JToggleablePasswordField#installation)
* [Gradle](https://github.com/Valkryst/JToggleablePasswordField#-gradle)
* [Maven](https://github.com/Valkryst/JToggleablePasswordField#-maven)
* [sbt](https://github.com/Valkryst/JToggleablePasswordField#-scala-sbt)
* [Example](https://github.com/Valkryst/JToggleablePasswordField#example)## Installation
JToggleablePasswordField is hosted on the [JitPack package repository](https://jitpack.io/#Valkryst/JToggleablePasswordField)
which supports Gradle, Maven, and sbt.###  Gradle
Add JitPack to your `build.gradle` at the end of repositories.
```
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
```Add JToggleablePasswordField as a dependency.
```
dependencies {
implementation 'com.github.Valkryst:JToggleablePasswordField:2025.03.01'
}
```###  Maven
Add JitPack as a repository.
``` xml
jitpack.io
https://jitpack.io
```
Add JToggleablePasswordField as a dependency.```xml
com.github.Valkryst
JToggleablePasswordField
2025.03.01```
###  Scala SBT
Add JitPack as a resolver.
```
resolvers += "jitpack" at "https://jitpack.io"
```Add JToggleablePasswordField as a dependency.
```
libraryDependencies += "com.github.Valkryst" % "JToggleablePasswordField" % "2025.03.01"
```## Features
* Adaptive styling which respects the current Look and Feel.
* Automatic scaling of the component's font and icon size based on the component's dimensions.
* Password visibility toggling with a clickable icon.## Example
This creates a new `JToggleablePasswordField` and displays it in a `JFrame`.
```java
public class Driver {
public static void main(final String[] args) {
SwingUtilities.invokeLater(() -> {
final JToggleablePasswordField passwordField = new JToggleablePasswordField("secret password");final JFrame frame = new JFrame("JToggleablePasswordField Example");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setPreferredSize(new Dimension(400, 100));final Container contentPane = frame.getContentPane();
contentPane.setLayout(new BorderLayout());
contentPane.add(passwordField, BorderLayout.CENTER);frame.setVisible(true);
frame.pack();
frame.setLocationRelativeTo(null);
});
}
}
```