Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.
Difference between revisions of "Nebula PasswordRevealer"
Line 4: | Line 4: | ||
This widget is an extension of a password text field. It behaves like a password widget, but it allows the user to reveal the password. | This widget is an extension of a password text field. It behaves like a password widget, but it allows the user to reveal the password. | ||
− | + | ||
+ | 2 behaviours are possible : | ||
+ | * If the flag '''SWT.PUSH''' is set, the eye button is a push button: when the button is pushed, the password is revealed | ||
+ | * If the flag '''SWT.PUSH''' is not set, when one clicks on the "eye" button besides the field: | ||
[[File:Passwordrevealer1.png]] | [[File:Passwordrevealer1.png]] |
Latest revision as of 07:16, 29 December 2020
Introduction
This widget is an extension of a password text field. It behaves like a password widget, but it allows the user to reveal the password.
2 behaviours are possible :
- If the flag SWT.PUSH is set, the eye button is a push button: when the button is pushed, the password is revealed
- If the flag SWT.PUSH is not set, when one clicks on the "eye" button besides the field:
The password is revealed until the user stops clicking:
Contents
Usage
You use this widget like a Text widget but you do not have to set the SWT.PASSWORD style :
final PasswordRevealer revealer = new PasswordRevealer(shell, SWT.NONE); revealer.setBackground(white);
All methods of the Text widget can be used :
String password = revealer.getText(); revealer.addListener(SWT.Modify, e-> System.out.println("Modified")); revealer.setForeground(foregroundColor); ...
You can change the "eye" icon if you wish:
For that you need to call the methods setImage() and setClickImage()
revelear.setImage(image); revelear.setClickImage(clickImage);
Examples
An example called PasswordRevealerSnippet.java is located in the plugin org.eclipse.nebula.widgets.passwordrevealer.snippets.
This example is also available here : PasswordRevealerSnippet.java